Bundler 2.2.7 installs binary gems on TruffleRuby, even though TruffleRuby sets Gem.platforms = [Gem::Platform::RUBY] in https://github.com/oracle/truffleruby/blob/15ab61bd57a9e6c30b5c58ccd544e04e7e275e8d/lib/truffle/rubygems/defaults/truffleruby.rb#L20-L23
With Gemfile
source 'https://rubygems.org'
gem "nokogiri"
and latest TruffleRuby (truffleruby-dev), or most likely also with the latest TruffleRuby release,
$ ruby-build truffleruby-dev ~/.rubies/truffleruby-dev
$ chruby truffleruby-dev
and then:
$ gem install bundler
Fetching bundler-2.2.7.gem
Successfully installed bundler-2.2.7
1 gem installed
$ bundle unstall
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies....
Using bundler 2.2.7
Fetching racc 1.5.2
Installing racc 1.5.2 with native extensions
Fetching nokogiri 1.11.1 (x86_64-linux)
Installing nokogiri 1.11.1 (x86_64-linux)
Bundle complete! 1 Gemfile dependency, 3 gems now installed.
Bundled gems are installed into `./vendor/bundle`
$ ruby -rnokogiri -e0
/home/eregon/.rubies/truffleruby-dev/lib/mri/rubygems/core_ext/kernel_require.rb:72:in `gem_original_require': Toplevel executable /home/eregon/.rubies/truffleruby-dev/lib/gems/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri/2.7/nokogiri.so does not contain bitcode (com.oracle.truffle.llvm.runtime.except.LLVMParserException) (RuntimeError)
Translated to internal error
from /home/eregon/.rubies/truffleruby-dev/lib/mri/rubygems/core_ext/kernel_require.rb:72:in `require'
from /home/eregon/.rubies/truffleruby-dev/lib/gems/gems/nokogiri-1.11.1-x86_64-linux/lib/nokogiri.rb:13:in `<top (required)>'
from <internal:core> core/kernel.rb:234:in `gem_original_require'
from /home/eregon/.rubies/truffleruby-dev/lib/mri/rubygems/core_ext/kernel_require.rb:168:in `require'
from <internal:core> core/unbound_method.rb:18:in `call'
from <internal:core> core/unbound_method.rb:18:in `bind_call'
from <internal:core> core/kernel.rb:272:in `require'
<internal:core> core/kernel.rb:236:in `gem_original_require': cannot load such file -- nokogiri (LoadError)
from /home/eregon/.rubies/truffleruby-dev/lib/mri/rubygems/core_ext/kernel_require.rb:92:in `require'
from <internal:core> core/unbound_method.rb:18:in `call'
from <internal:core> core/unbound_method.rb:18:in `bind_call'
from <internal:core> core/kernel.rb:272:in `require'
Bundler chooses the precompiled binary for nokogiri, but that is incorrect because that links against MRI's ABI.
Using gem install does not pick the precompiled binary, as expected:
$ gem install nokogiri
Fetching mini_portile2-2.5.0.gem
Fetching nokogiri-1.11.1.gem
Successfully installed mini_portile2-2.5.0
Building native extensions. This could take a while...
Successfully installed nokogiri-1.11.1
2 gems installed
gem i nokogiri 63.45s user 2.96s system 561% cpu 11.837 total
$ ruby -rnokogiri -e0
OK
@chrisseaton noticed this.
Related: https://github.com/rubygems/rubygems/issues/2945
bundle env and paste the output belowBundler 2.2.7
Platforms ruby
Ruby 2.7.2p0 (2021-01-27 revision 93211d3fa80390c158a08e9be0f662783e5146ab) [x86_64-linux]
Full Path /home/eregon/.rubies/truffleruby-dev/bin/truffleruby
Config Dir /home/runner/work/truffleruby-dev-builder/truffleruby-dev-builder/etc
RubyGems 3.1.4
Gem Home /home/eregon/.rubies/truffleruby-dev/lib/gems
Gem Path /home/eregon/.gem/truffleruby/21.1.0-dev-93211d3f:/home/eregon/.rubies/truffleruby-dev/lib/gems
User Home /home/eregon
User Path /home/eregon/.gem/truffleruby/21.1.0-dev-93211d3f
Bin Dir /home/eregon/.rubies/truffleruby-dev/bin
Tools
Git 2.26.2
RVM not installed
rbenv not installed
chruby 0.3.9
Built At 2021-01-27
Git SHA 7bc7ecb660
Released Version true
source 'https://rubygems.org'
gem "nokogiri"
GEM
remote: https://rubygems.org/
specs:
nokogiri (1.11.1-x86_64-linux)
racc (~> 1.4)
racc (1.5.2)
PLATFORMS
x86_64-linux
DEPENDENCIES
nokogiri
BUNDLED WITH
2.2.7
Thanks for the report @eregon, I'll fix this next week.
In case you get some reports before I fix this and want to provide a workaround, bundle config set --local force_ruby_platform true should do the trick I believe.
Thank you, I can confirm the workaround works:
$ bundle install
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies....
Using bundler 2.2.7
Using racc 1.5.2
Fetching nokogiri 1.11.1 (x86_64-linux)
Installing nokogiri 1.11.1 (x86_64-linux)
Bundle complete! 1 Gemfile dependency, 3 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
$ rm -rf Gemfile.lock vendor .bundle
$ bundle config set --local force_ruby_platform true
$ bundle install
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Using bundler 2.2.7
Using mini_portile2 2.5.0
Using racc 1.5.2
Fetching nokogiri 1.11.1
Installing nokogiri 1.11.1 with native extensions
Bundle complete! 1 Gemfile dependency, 4 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Most helpful comment
Thanks for the report @eregon, I'll fix this next week.