mini_racer: Bundle install of 0.6.1 fails on Heroku with Ruby 3.1.0

Apologies if this is a duplicate, I’ve been searching around and wrestling with this for a couple of hours but have had no luck.

I’m in the process of upgrading a Heroku rails app to Ruby 3.1.0, and am getting an error deploying to Heroku during the bundle install step:

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

current directory:
/tmp/build_daf26635/vendor/bundle/ruby/3.1.0/gems/mini_racer-0.6.1/ext/mini_racer_extension
/tmp/build_daf26635/vendor/ruby-3.1.0/bin/ruby -I
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0 -r
./siteconf20220114-209-758jwm.rb extconf.rb
checking for -lpthread... yes
creating Makefile

current directory:
/tmp/build_daf26635/vendor/bundle/ruby/3.1.0/gems/mini_racer-0.6.1/ext/mini_racer_extension
make DESTDIR\= clean

current directory:
/tmp/build_daf26635/vendor/bundle/ruby/3.1.0/gems/mini_racer-0.6.1/ext/mini_racer_extension
make DESTDIR\=
compiling mini_racer_extension.cc
linking shared-object mini_racer_extension.so
g++: error:
/tmp/build_daf26635/vendor/bundle/ruby/3.1.0/gems/libv8-node-16.10.0.0-x86_64-linux-musl/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a:
No such file or directory
make: *** [Makefile:263: mini_racer_extension.so] Error 1

make failed, exit code 2

Gem files will remain installed in
/tmp/build_daf26635/vendor/bundle/ruby/3.1.0/gems/mini_racer-0.6.1 for
inspection.
Results logged to
/tmp/build_daf26635/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/mini_racer-0.6.1/gem_make.out

/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in
`run'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:44:in
`block in make'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in
`each'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in
`make'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:63:in
`block in build'
  /tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/tempfile.rb:317:in `open'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in
`build'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in
`build_extension'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in
`block in build_extensions'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in
`each'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in
`build_extensions'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/rubygems/installer.rb:847:in
`build_extensions'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:71:in
`build_extensions'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:28:in
`install'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/source/rubygems.rb:204:in
`install'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:54:in
`install'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:186:in
`do_install'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:62:in
`apply_func'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:57:in
`block in process_queue'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:54:in
`loop'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:54:in
`process_queue'
/tmp/build_daf26635/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/worker.rb:91:in
`block (2 levels) in create_threads'

An error occurred while installing mini_racer (0.6.1), and Bundler cannot
continue.

In Gemfile:
  mini_racer

Failed to install gems via Bundler.

Push rejected, failed to compile Ruby app.
Push failed

Versions of things are as follows:

  • Heroku stack: heroku-20
  • Ruby version: 3.1.0
  • Rails version: 6.1.4.4
  • mini_racer version: 0.6.1

I’ve had a look to see if there’s some way for me to view those files in /tmp/ for more information, but as far as I can tell they’re emphemeral and disppear when the build fails. I thought it best to bring this here in case there’s something simple I’m missing.

Thanks in advance for having a look!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 25 (2 by maintainers)

Most upvoted comments

@Ecco I’m not 100% sure, but AFAIK gem install libv8-node --version 16.10.0.0 --platform x86_64-linux-libc should do the trick. https://github.com/rubygems/rubygems/pull/4488 is the (or one?) related issue over at RubyGems.

I’ll add a troubleshooting guide shortly, because it’s always the same issue unfortunately 😞

@csuhta please make sure you have set the proper platforms in Gemfile.lock using:

  • bundle lock --add-platform x86_64-linux
  • bundle lock --add-platform x86_64-darwin-21

This is a known issue with Rubygems where the platform is not resolved properly. In your logs you see, that the musl is to be installed (/tmp/build_a1a5338c/vendor/bundle/ruby/3.1.0/gems/libv8-node-16.10.0.0-x86_64-linux-musl/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a) although you probably run glibc.