mini_racer gem 0.8.0 fails bundle install with Ruby 3.1.x
Asked Answered
A

1

5

This problem has been reported in the past and apparently solved by an update to mini_racer. But I've hit a brick wall here that I can't get past so it appears to be the same problem again but possibly for different reasons. I have encountered the problem first when I tried to upgrade from Ruby 3.0.2 to Ruby 3.1.0, and had the same problem with a fresh install of everything. Also, when I tried to switch back to Ruby 3.0.2 and run bundle install I got exactly the same error.

I've also tried using older versions of mini_racer, with no change. I don't have the knowledge to debug mini_racer or bundler. The mkmf.log file didn't tell me anything useful but I don't know how to decrypt it.

When I run bundle install I consistently get the following. The files indicated in the troubleshooting steps are many layers beyond my understanding to begin to dig into what might be going wrong. It's the same error previously reported for earlier mini_racer / Ruby versions but I haven't found a current solution.

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

    current directory: /home/erik/.rvm/gems/ruby-3.1.0/gems/mini_racer-0.8.0/ext/mini_racer_extension
/home/erik/.rvm/rubies/ruby-3.1.0/bin/ruby -I /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0 -r ./siteconf20231202-16840-vjvf4h.rb extconf.rb
checking for -lpthread... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/erik/.rvm/rubies/ruby-3.1.0/bin/$(RUBY_BASE_NAME)
    --with-pthread-dir
    --without-pthread-dir
    --with-pthread-include
    --without-pthread-include=${pthread-dir}/include
    --with-pthread-lib
    --without-pthread-lib=${pthread-dir}/lib
    --with-pthreadlib
    --without-pthreadlib
    --enable-debug
    --disable-debug
    --enable-asan
    --disable-asan
/home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/psych.rb:455:in `parse_stream': undefined method `parse' for #<Psych::Parser:0x00007f85c2b965c8
@handler=#<Psych::Handlers::DocumentStream:0x00007f85c2b96a78 @stack=[], @last=nil, @root=nil, @start_line=nil, @start_column=nil, @end_line=nil, @end_column=nil, @block=#<Proc:0x00007f85c2b96690
/home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/psych.rb:399>>, @external_encoding=0> (NoMethodError)

      parser.parse yaml, filename
            ^^^^^^
    from /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/psych.rb:399:in `parse'
    from /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/psych.rb:272:in `unsafe_load'
    from /home/erik/.rvm/gems/ruby-3.1.0/gems/libv8-node-18.16.0.0-x86_64-linux/ext/libv8-node/location.rb:21:in `block in load!'
    from /home/erik/.rvm/gems/ruby-3.1.0/gems/libv8-node-18.16.0.0-x86_64-linux/ext/libv8-node/location.rb:20:in `open'
    from /home/erik/.rvm/gems/ruby-3.1.0/gems/libv8-node-18.16.0.0-x86_64-linux/ext/libv8-node/location.rb:20:in `load!'
    from /home/erik/.rvm/gems/ruby-3.1.0/gems/libv8-node-18.16.0.0-x86_64-linux/lib/libv8/node.rb:8:in `configure_makefile'
    from extconf.rb:77:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/erik/.rvm/gems/ruby-3.1.0/extensions/x86_64-linux/3.1.0/mini_racer-0.8.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/erik/.rvm/gems/ruby-3.1.0/gems/mini_racer-0.8.0 for inspection.
Results logged to /home/erik/.rvm/gems/ruby-3.1.0/extensions/x86_64-linux/3.1.0/mini_racer-0.8.0/gem_make.out

  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/tempfile.rb:317:in `open'
  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in build_extensions'
  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
  /home/erik/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/installer.rb:847:in `build_extensions'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/source/rubygems.rb:203:in `install'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:54:in `install'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:130:in `do_install'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:121:in `block in worker_pool'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/worker.rb:62:in `apply_func'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/worker.rb:57:in `block in process_queue'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in `loop'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in `process_queue'
  /home/erik/.rvm/gems/ruby-3.1.0/gems/bundler-2.4.22/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'

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

In Gemfile:
  mini_racer

Contents of the mkmf.log file:

have_library: checking for -lpthread... -------------------- yes

LD_LIBRARY_PATH=.:/home/erik/.rvm/rubies/ruby-3.1.0/lib "gcc -o conftest -I/home/erik/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-linux -I/home/erik/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/home/erik/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0 -I.    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC conftest.c  -L. -L/home/erik/.rvm/rubies/ruby-3.1.0/lib -Wl,-rpath,/home/erik/.rvm/rubies/ruby-3.1.0/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed     -Wl,-rpath,'/../lib' -Wl,-rpath,'/../lib' -lruby  -lm  -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

LD_LIBRARY_PATH=.:/home/erik/.rvm/rubies/ruby-3.1.0/lib "gcc -o conftest -I/home/erik/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-linux -I/home/erik/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/home/erik/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0 -I.    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC conftest.c  -L. -L/home/erik/.rvm/rubies/ruby-3.1.0/lib -Wl,-rpath,/home/erik/.rvm/rubies/ruby-3.1.0/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed     -Wl,-rpath,'/../lib' -Wl,-rpath,'/../lib' -lruby -lpthread  -lm  -lc"
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11: 
12:   return !!argv[argc];
13: }
14: 
15: int t(void) { ; return 0; }
/* end */

--------------------


I am in the process of trying to upgrade my project from Ruby 3.0.4 / Rails 6.1.4 to Ruby 3.1.3 / Rails 7.0.8. Rebuilt existing project that was previously running successfully in Ruby 3.0.4 / Rails 6.1.4 Upgraded Rails to 7.0.8 - bundle install completed successfully Switched to Ruby 3.1.3 - bundle install failed (expected to pass) - error as described Switched to Ruby 3.1.0 - bundle install failed (expected to pass) - error as described Switched to Ruby 3.0.4 - bundle install failed (expected to pass) - error as described

Rebuilt project from a clean install (Ubuntu 22.04.3) with Ruby 3.1.0 - bundle install failed (expected to pass) error as described

Arvy answered 3/12, 2023 at 2:35 Comment(0)
C
7

To quote Andy Allan from rubyjs/mini_racer#289:

For anyone else coming across this, this was caused by a bug in rubygems < 3.4.9. So you can also fix it on older versions of ruby (e.g. ruby 3.0, 3.1) by updating your version of rubygems:

gem update --system

See rubygems/rubygems#6490 for the PR in rubygems that fixed this bug, which was released in rubygems 3.4.10.

Caseose answered 3/12, 2023 at 13:2 Comment(1)
Yup. That was the magic answer. Thank you thank you !Arvy

© 2022 - 2024 — McMap. All rights reserved.