Skip to content

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. #8704

@rohmansca

Description

@rohmansca

Describe the problem as clearly as you can

When upgrading Ruby to 3.4.3 with RubyGems >= 3.6.0,
I'm encountering an error when running bundle install that affects several gems with native extensions (e.g., bigdecimal, bcrypt, msgpack, bson, google-protobuf, etc). The error traceback includes:

make [:target_rbconfig, #<Gem::TargetRbConfig:0x00007ff0768334c0 @rbconfig=RbConfig, @path=nil>]
failedno implicit conversion of Array into String

This only occurs when installing via bundle install. The same gems install fine when using gem install, e.g.:

gem install bigdecimal

works correctly.

Did you try upgrading RubyGems?

Yes. I'm using:

  • RubyGems version: 3.6.7
  • Bundler version: 2.6.7

The issue exists in RubyGems 3.6.0 – 3.6.9.
It does not exist in 3.5.23.
Unfortunately, downgrading RubyGems is not possible in CI environments using ruby/setup-ruby@v1, which requires 3.6.7+.

Post steps to reproduce the problem

Here is a minimal reproduction setup in a Dockerfile:

FROM public.ecr.aws/docker/library/ruby:3.4.3-slim

WORKDIR /app

RUN bundle config set frozen 'true'
RUN bundle config set without 'development test'

RUN apt-get update &&
apt-get install --no-install-recommends -y git build-essential nodejs &&
apt-get autoremove -y

ADD . /app

RUN bundle install

Which command did you run?

bundle install

What were you expecting to happen?

I expected the gems (e.g., bigdecimal) to install successfully, since they build correctly when installed individually using gem install.

What actually happened?

The installation failed with:

current directory: /vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9/ext/bigdecimal
make DESTDIR= sitearchdir=./.gem.20250520-14-rg0za4 sitelibdir=./.gem.20250520-14-rg0za4 [:target_rbconfig,
#<Gem::TargetRbConfig:0x00007ff0768334c0\ @rbconfig=RbConfig,\ @path=nil>]
make [:target_rbconfig, #<Gem::TargetRbConfig:0x00007ff0768334c0 @rbconfig=RbConfig, @path=nil>] failedno implicit conversion of
Array into String

Gem files will remain installed in /vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9 for inspection.
Results logged to /vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/bigdecimal-3.1.9/gem_make.out

/usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:103:in 'Gem::Ext::Builder.run'
/usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:52:in 'block in Gem::Ext::Builder.make'
/usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:44:in 'Hash#each'
/usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:44:in 'Gem::Ext::Builder.make'
/app/Gemfile:43:in 'make'
/app/Gemfile:43:in 'make'
/usr/local/lib/ruby/3.4.0/rubygems/ext/ext_conf_builder.rb:44:in 'Gem::Ext::ExtConfBuilder.build'
/usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:195:in 'Gem::Ext::Builder#build_extension'
/usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:229:in 'block in Gem::Ext::Builder#build_extensions'
/usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:226:in 'Array#each'
/usr/local/lib/ruby/3.4.0/rubygems/ext/builder.rb:226:in 'Gem::Ext::Builder#build_extensions'
/usr/local/lib/ruby/3.4.0/rubygems/installer.rb:844:in 'Gem::Installer#build_extensions'
/usr/local/lib/ruby/3.4.0/bundler/rubygems_gem_installer.rb:111:in 'Bundler::RubyGemsGemInstaller#build_extensions'
/usr/local/lib/ruby/3.4.0/bundler/rubygems_gem_installer.rb:30:in 'Bundler::RubyGemsGemInstaller#install'
/usr/local/lib/ruby/3.4.0/bundler/source/rubygems.rb:220:in 'Bundler::Source::Rubygems#install'
/usr/local/lib/ruby/3.4.0/bundler/installer/gem_installer.rb:55:in 'Bundler::GemInstaller#install'
/usr/local/lib/ruby/3.4.0/bundler/installer/gem_installer.rb:17:in 'Bundler::GemInstaller#install_from_spec'
/usr/local/lib/ruby/3.4.0/bundler/installer/parallel_installer.rb:133:in 'Bundler::ParallelInstaller#do_install'
/usr/local/lib/ruby/3.4.0/bundler/installer/parallel_installer.rb:124:in 'block in Bundler::ParallelInstaller#worker_pool'
/usr/local/lib/ruby/3.4.0/bundler/worker.rb:62:in 'Bundler::Worker#apply_func'
/usr/local/lib/ruby/3.4.0/bundler/worker.rb:57:in 'block in Bundler::Worker#process_queue'
internal:kernel:168:in 'Kernel#loop'
/usr/local/lib/ruby/3.4.0/bundler/worker.rb:54:in 'Bundler::Worker#process_queue'
/usr/local/lib/ruby/3.4.0/bundler/worker.rb:90:in 'block (2 levels) in Bundler::Worker#create_threads'

An error occurred while installing bigdecimal (3.1.9), and Bundler cannot continue.

In Gemfile:
rails was resolved to 7.2.2.1, which depends on
actioncable was resolved to 7.2.2.1, which depends on
actionpack was resolved to 7.2.2.1, which depends on
actionview was resolved to 7.2.2.1, which depends on
rails-dom-testing was resolved to 2.2.0, which depends on
activesupport was resolved to 7.2.2.1, which depends on
bigdecimal

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

Run gem env and paste the output below

RubyGems Environment:

  • RUBYGEMS VERSION: 3.6.7
  • RUBY VERSION: 3.4.3 (2025-04-14 patchlevel 32) [x86_64-linux]
  • INSTALLATION DIRECTORY: /usr/local/bundle
  • USER INSTALLATION DIRECTORY: /root/.local/share/gem/ruby/3.4.0
  • CREDENTIALS FILE: /root/.local/share/gem/credentials
  • RUBY EXECUTABLE: /usr/local/bin/ruby
  • GIT EXECUTABLE: /usr/bin/git
  • EXECUTABLE DIRECTORY: /usr/local/bundle/bin
  • SPEC CACHE DIRECTORY: /root/.cache/gem/specs
  • SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86_64-linux
  • GEM PATHS:
    • /usr/local/bundle
    • /root/.local/share/gem/ruby/3.4.0
    • /usr/local/lib/ruby/gems/3.4.0
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :backtrace => true
    • :bulk_threshold => 1000
    • "gem" => "--no-document"
  • REMOTE SOURCES:
  • SHELL PATH:
    • /usr/local/bundle/bin
    • /usr/local/sbin
    • /usr/local/bin
    • /usr/sbin
    • /usr/bin
    • /sbin
    • /bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions