Bundle install Failed to build gem native extension

hey,
my builds started to fail without any code changes on my side. The error I get is when running the bundle "_2.3.24_" "install" " is

Installing fastlane-plugin-firebase_app_distribution 0.7.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/json-2.6.3/ext/json/ext/generator
/Users/vagrant/.asdf/installs/ruby/3.1.3/bin/ruby -I
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0 extconf.rb
mkmf.rb can't find header files for ruby at
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/json-2.6.3 for
inspection.
Results logged to
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/extensions/arm64-darwin-22/3.1.0-static/json-2.6.3/gem_make.out
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/rubygems/ext/builder.rb:102:in
`run'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:28:in
`build'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/rubygems/ext/builder.rb:171:in
`build_extension'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/rubygems/ext/builder.rb:205:in
`block in build_extensions'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/rubygems/ext/builder.rb:202:in
`each'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/rubygems/ext/builder.rb:202:in
`build_extensions'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/3.1.0/rubygems/installer.rb:843:in
`build_extensions'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/rubygems_gem_installer.rb:72:in
`build_extensions'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/source/rubygems.rb:207:in
`install'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/installer/gem_installer.rb:54:in
`install'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/installer/parallel_installer.rb:186:in
`do_install'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/worker.rb:62:in
`apply_func'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/worker.rb:57:in
`block in process_queue'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/worker.rb:54:in
`loop'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/worker.rb:54:in
`process_queue'
/Users/vagrant/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/bundler-2.3.24/lib/bundler/worker.rb:91:in
`block (2 levels) in create_threads'
An error occurred while installing json (2.6.3), and Bundler cannot continue.
In Gemfile:
  fastlane was resolved to 2.214.0, which depends on
    json

My Gemfile has dependency only to fastlane

gem 'fastlane'

which is resolved to fastlane (2.211.0) in the Gemfile.lock

I tried updating the gems using gem update bundler + commit but it does not seem to help.

I can provide the links to the builds which succeeded and to the builds that failed. Both have the exact code base.

I’m using ruby 3.1.3 which is pinned in the .ruby-version file

any idea why it started to fail suddenly?

thanks for your help

3 Likes

it seems that updating my ruby version to 3.2.1 fixed the issue.

I still wonder though what was the real cause of it

1 Like

Ruby 3.2 added native gem support which most of the native gems you’d depend on (Nokogiri is usually the main problem when installing fastlane) supports. Do you commit a lockfile?

Yes, the Gemfile.lock is committed so I wonder why the builds started to fail even if nothing changed in the lockfile

Ruby 3.2 added native gem support

What do you mean with the native gem support? I don’t see something like that mentioned in the Ruby 3.2 changelog: Ruby 3.2.0 Released.

I wonder why the builds started to fail even if nothing changed in the lockfile

This also happened to me, I bet something changed in the build host image, even though there is nothing relevant in the image logs

https://github.com/bitrise-io/bitrise.io/tree/master/system_reports/MACOS/M1/.

I’m also having this problem. It started on Friday

Ruby 3.2 added native gem support

Also the builds started to fail when Ruby was pinned to 3.1.3

I don’t 100% understand the Ruby side of things, but in progress: ship native gem with precompiled Ruby 3.2 support · Issue #2740 · sparklemotion/nokogiri · GitHub is the Nokogiri implementation ticket.

This also happened to our app - is there some way to get notification for when underlying host machine change?

Ah I see this is it.