rubyjs / mini_racer

Minimal embedded v8
MIT License
598 stars 93 forks source link

Bundle install fails on CircleCI for mini_racer 0.6.0 #227

Closed chrisalley closed 2 years ago

chrisalley commented 2 years ago

When running the bundle install command on CircleCI with mini_racer 0.6.0 in the Gemfile, the build fails. This did not occur with mini_racer 0.3.1. Output:

Installing libv8-node 16.10.0.0 (x86_64-linux-musl)
Fetching mini_racer 0.6.0
Installing mini_racer 0.6.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/circleci/project/vendor/bundle/ruby/3.0.0/gems/mini_racer-0.6.0/ext/mini_racer_extension
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.0.0 -r
./siteconf20220110-93-zv602o.rb extconf.rb
checking for -lpthread... yes
creating Makefile

current directory:
/home/circleci/project/vendor/bundle/ruby/3.0.0/gems/mini_racer-0.6.0/ext/mini_racer_extension
make DESTDIR\= clean

current directory:
/home/circleci/project/vendor/bundle/ruby/3.0.0/gems/mini_racer-0.6.0/ext/mini_racer_extension
make DESTDIR\=
compiling mini_racer_extension.cc
linking shared-object mini_racer_extension.so
g++: error:
/home/circleci/project/vendor/bundle/ruby/3.0.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:262: mini_racer_extension.so] Error 1

make failed, exit code 2

Gem files will remain installed in
/home/circleci/project/vendor/bundle/ruby/3.0.0/gems/mini_racer-0.6.0 for
inspection.
Results logged to
/home/circleci/project/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mini_racer-0.6.0/gem_make.out

An error occurred while installing mini_racer (0.6.0), and Bundler
cannot continue.
Make sure that `gem install mini_racer -v '0.6.0' --source
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  mini_racer

Exited with code exit status 5
CircleCI received exit code 5
tisba commented 2 years ago

Just a sanity check: Are you running on alpine?

chrisalley commented 2 years ago

It's not alpine based; the specific image/tag is ruby:3.0.3.

tisba commented 2 years ago

This looks very similar to https://github.com/rubyjs/mini_racer/issues/218

tisba commented 2 years ago

Installing libv8-node 16.10.0.0 (x86_64-linux-musl)

This looks wrong then, @chrisalley.

cmoad commented 2 years ago

Seeing the same issue in GitHub Actions with the latest ruby/setup-ruby@v1.91.0

Error output ``` Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/runner/work/gandalf/gandalf/vendor/bundle/ruby/2.7.0/gems/mini_racer-0.6.1/ext/mini_racer_extension /opt/hostedtoolcache/Ruby/2.7.5/x64/bin/ruby -I /opt/hostedtoolcache/Ruby/2.7.5/x64/lib/ruby/2.7.0 -r ./siteconf20220113-1736-1e9g79d.rb extconf.rb checking for -lpthread... yes creating Makefile current directory: /home/runner/work/gandalf/gandalf/vendor/bundle/ruby/2.7.0/gems/mini_racer-0.6.1/ext/mini_racer_extension make "DESTDIR=" clean current directory: /home/runner/work/gandalf/gandalf/vendor/bundle/ruby/2.7.0/gems/mini_racer-0.6.1/ext/mini_racer_extension make "DESTDIR=" compiling mini_racer_extension.cc mini_racer_extension.cc: In function ‘VALUE convert_v8_to_ruby(v8::Isolate*, v8::Local, v8::Local)’: mini_racer_extension.cc:560:18: warning: ‘stackCounter.StackCounter::isolate’ may be used uninitialized in this function [-Wmaybe-uninitialized] 560 | StackCounter stackCounter(isolate); | ^~~~~~~~~~~~ linking shared-object mini_racer_extension.so g++: error: /home/runner/work/gandalf/gandalf/vendor/bundle/ruby/2.7.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:262: mini_racer_extension.so] Error 1 make failed, exit code 2 Gem files will remain installed in /home/runner/work/gandalf/gandalf/vendor/bundle/ruby/2.7.0/gems/mini_racer-0.6.1 for inspection. Results logged to /home/runner/work/gandalf/gandalf/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/mini_racer-0.6.1/gem_make.out An error occurred while installing mini_racer (0.6.1), and Bundler cannot continue. Make sure that `gem install mini_racer -v '0.6.1'` succeeds before bundling. In Gemfile: mini_racer ```
justinsnair commented 2 years ago

Same issue here with the ruby:3.0.2 image and mini_racer 0.5.0

mdh commented 2 years ago

Fwiw, we were finally able to resolve our issue by updating to latest bundler(2.3.5), as well as specifying platforms in Gemfile.lock. We are still running Ruby 2.7.x.

tisba commented 2 years ago

If you are running into this issue, please make sure to update bundler (currently 2.3.5) and check if the platform you're running on is properly set in Gemfile.lock (via bundle lock --add-platform aarch64-linux).

mini_racer 0.6.2 should work fine with Ruby 2.6.9, 2.7.5, 3.0.x and 3.1.0 (I tested a lot of those combination across x86 and aarch64 recently). Especially with the recent 0.6.2 the last issues with pre Ruby 3 environments got fixed.

@mdh: awesome 👍 @justinsnair, @cmoad: Could you try with mini_racer 0.6.2?

chrisalley commented 2 years ago

Solved with:

bundle lock --add-platform aarch64-linux
bundle lock --add-platform x86_64-linux

In Gemfile:

gem 'mini_racer', '~> 0.6.2'

In Dockerfile:

FROM ruby:3.0.3
...
RUN gem install bundler --version=2.3.5
RUN bundle install

Only aarch64-linux was required as an added platform for CircleCI to succeed in installing mini_racer, but another gem (ransack) failed to install without x86_64-linux being added also.

tisba commented 2 years ago

Great! I'm glad this worked out for you, @chrisalley!

Only aarch64-linux was required as an added platform for CircleCI to succeed

Interesting 🤔 Didn't knew that CircleCI has an ARM offering :)

vertalm commented 2 years ago

My point to this issue gem install libv8-node --version 16.10.0.0 --platform x86_64-linux-libc