rubyjs / mini_racer

Minimal embedded v8
MIT License
594 stars 93 forks source link

Installing mini_racer 0.6 on docker M1 fails with "make: printf: Argument list too long" #272

Closed diaclavijo closed 1 year ago

diaclavijo commented 1 year ago

Hello,

I'm working with Docker on M1 Macbook Pro, then when I am trying to update the project from mini_racer 0.4 to 0.6 to support ruby 3.1 it is failing while doing bundle install. See return at bottom.

The problem seems related to libv8-node (16.10.0.0).

On another hand, it works fine while installing it locally (not docker).

...
  touch /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/libv8-node-16.10.0.0/src/node-v16.10.0/out/Release/obj.target/tools/v8_gypfiles/v8_compiler_for_mksnapshot.stamp
make: printf: Argument list too long
make: *** [tools/v8_gypfiles/v8_base_without_compiler.target.mk:1021:
/opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/libv8-node-16.10.0.0/src/node-v16.10.0/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a] Error 127
rm 124a24bf1de8859beea1c6175a3a36094ad7da5b.intermediate e320af0d9616fd7dc4d7dcfabbe4655f4d0793cb.intermediate
make: Leaving directory '/opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/libv8-node-16.10.0.0/src/node-v16.10.0/out'
/opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/libv8-node-16.10.0.0/ext/libv8-node/builder.rb:14:in `build_libv8!': failed to build libv8 16.10.0 (Libv8::Node::BuilderError)
    from /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/libv8-node-16.10.0.0/ext/libv8-node/location.rb:30:in `install!'
    from extconf.rb:9:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/libv8-node-16.10.0.0 for inspection.
Results logged to /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/extensions/aarch64-linux/3.0.0/libv8-node-16.10.0.0/gem_make.out

  /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:102:in `run'
  /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:28:in `build'
  /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:171:in `build_extension'
  /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:205:in `block in build_extensions'
  /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:202:in `each'
  /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:202:in `build_extensions'
  /usr/local/lib/ruby/site_ruby/3.0.0/rubygems/installer.rb:843:in `build_extensions'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/source/rubygems.rb:204:in `install'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/installer/gem_installer.rb:54:in `install'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/worker.rb:62:in `apply_func'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/worker.rb:57:in `block in process_queue'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/worker.rb:54:in `loop'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/worker.rb:54:in `process_queue'
  /opt/helpling/vendor/bundle/ruby/2.6.0/ruby/3.0.0/gems/bundler-2.3.10/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'

An error occurred while installing libv8-node (16.10.0.0), and Bundler cannot continue.

In Gemfile:
  mini_racer was resolved to 0.6.3, which depends on
    libv8-node
The last command has exited with non-zero code (1280).

Tip: use --help to see all available options
tisba commented 1 year ago

Looks like you're on Ruby 2.6.0 which is EOL since 2022-04-12. mini_racer only supports non-EOL'd Rubies (see here). You might be able to install earlier versions of mini_racer.

That being said, can you run the following script via docker run -it --rm -v "$(pwd)":/app -w /app ruby:2.6.10 ruby /app/minimal.rb?

require "bundler/inline"

gemfile do
  source "https://rubygems.org"

  gem "mini_racer"
end

require "libv8-node"

puts "RUBY_VERSION : #{RUBY_VERSION}"
puts "RUBY_PLATFORM: #{RUBY_PLATFORM}"
puts "MiniRacer::VERSION: #{MiniRacer::VERSION}"
puts "MiniRacer::LIBV8_NODE_VERSION: #{MiniRacer::LIBV8_NODE_VERSION}"
puts "Libv8::Node::VERSION: #{Libv8::Node::VERSION}"
puts "Libv8::Node::NODE_VERSION: #{Libv8::Node::NODE_VERSION}"
puts "Libv8::Node::LIBV8_VERSION: #{Libv8::Node::LIBV8_VERSION}"

ctx = MiniRacer::Context.new

puts ctx.eval("1+1")

On my M1 MacBook Pro (on MacOS 13.1) it works fine even on Ruby 2.6.10:

$ docker run -it --rm -v "$(pwd)":/app ruby:2.6.10 ruby /app/minimal.rb
RUBY_VERSION : 2.6.10
RUBY_PLATFORM: aarch64-linux
MiniRacer::VERSION: 0.6.3
MiniRacer::LIBV8_NODE_VERSION: ~> 16.10.0.0
Libv8::Node::VERSION: 16.10.0.0
Libv8::Node::NODE_VERSION: 16.10.0
Libv8::Node::LIBV8_VERSION: 9.3.345.19
2
diaclavijo commented 1 year ago

No, i'm on ruby 3.0.

I had to do force this to have the platform aarch64-linux in my Gemfile os it will pick up the right binaries, as I understand it.

I run bundle lock --add-platform aarch64-linux

I believe the issue is related to bundler.

Code-kunkun commented 1 year ago

@diaclavijo hi, I'm working with m1, but i meet the issue like this

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

can you tell me how you solved it? Thanks.

tisba commented 1 year ago

Hey @Code-kunkun. Without any further information on your setup/environment, logs, … it's impossible to help. Please check https://github.com/rubyjs/mini_racer/#troubleshooting. @diaclavijo's missing platform in Gemfile.lock is also described there.