Truffleruby: Couldn't install truffleruby 20.2.0 with ruby-build on macOS

Created on 21 Aug 2020  路  12Comments  路  Source: oracle/truffleruby

@eregon I try to install 20.2.0 on macOS today. But it was failed. 20.1.0 is works fine with same environment.

see https://gist.github.com/hsbt/82d9eae64ccbc3a4cc648ad973ab00a6

installing

All 12 comments

Thank you for the report.

I cannot reproduce on Linux with:

$ bin/ruby-build truffleruby-20.2.0 ~/.rubies/truffleruby-20.2.0

I'll ask my colleagues on macOS to see if they can reproduce.

Do you have any RUBY* environment variable defined like RUBYOPT or RUBYLIB?

env | grep -E 'RUBY|gem'

Do you have any RUBY* environment variable defined like RUBYOPT or RUBYLIB?

Nothing.

$ env | rg RUBY
RUBY_CODESIGN=hsbt

I could install 20.2.0 with removing GEM_HOME environment. I'm not sure why it caused this issue.

$ env | rg GEM
GEMRC=/Users/hsbt/.config/gem/gemrc
GEM_HOME=/Users/hsbt/.local/share/gem
GEM_SPEC_CACHE=/Users/hsbt/.cache/gem
$ set -e GEM_HOME
$ rbenv install truffleruby-20.2.0
ruby-build: using openssl from homebrew
Installing truffleruby-20.2.0...
Recompiling the OpenSSL C extension (against the installed libssl)
checking for openssl/ssl.h... yes
checking for OpenSSL version is 1.0.1 or later... yes
(snip)
compiling ossl_x509store.c
linking shared-object openssl.bundle
TruffleRuby was successfully installed in /Users/hsbt/.local/share/rbenv/versions/truffleruby-20.2.0
Installed truffleruby-20.2.0 to /Users/hsbt/.local/share/rbenv/versions/truffleruby-20.2.0

If you have a point of the next investigation, Can you share to me? Thanks.

From the backtrace, it's failing to require fileutils here:
https://github.com/oracle/truffleruby/blob/vm-20.2.0/lib/mri/mkmf.rb

But of course it should find it since it is in the stdlib, under truffleruby-20.2.0/lib/mri/fileutils.rb.
Can you make sure this file exists and is readable on your installation?

It might be worth trying to disable RubyGems while running that code, since anyway RubyGems should not be needed for Recompiling the OpenSSL C extension (against the installed libssl).
Can you try with TRUFFLERUBYOPT="--disable-gems -rrbconfig" rbenv install truffleruby-20.2.0 ?

@hsbt Do you have the fileutils gem installed in that GEM_HOME?
I think that's a cause of this issue, because then on require 'fileutils', TruffleRuby will try to load RubyGems + that fileutils gem, and that doesn't work well (which might be a bug).

Ah, Yes.

$ ls .local/share/gem/gems/fileutils-1.4.1/
fileutils.gemspec lib LICENSE.txt Rakefile README.md

Do you also have a stringio gem in that GEM_HOME? I think that starts to explain it.
In that case we have 2 "upgraded default gems" (fileutils and stringio), and when requiring RubyGems to load the first one, RubyGems itself will require stringio, and then we have a sort of cycle of loading RubyGems, which is detected and that's why this error is raised.

Also yes.

$ ls .local/share/gem/gems/stringio-0.1.3/
ext lib README.md

RubyGems itself will require stringio, and then we have a sort of cycle of loading RubyGems, which is detected and that's why this error is raised.

Maked sense. I have no idea to resolve this case because I'm not familiar with build process of truffleruby.

I can reproduce now with, on MRI:

GEM_HOME=$PWD/gem_home gem i fileutils stringio 

and then on TruffleRuby:

$ GEM_HOME=$PWD/gem_home truffleruby -rfileutils -e0
<internal:core> core/kernel.rb:265:in `require': RubyGems did not redefine #require as expected, make sure $LOAD_PATH and home are set correctly (RuntimeError)
...

Actually there is a warning about having GEM_HOME set incorrectly:

$ GEM_HOME=$PWD/gem_home truffleruby -e 'Gem'                       
[ruby] WARNING gem paths: /home/eregon/code/truffleruby-ws/truffleruby/gem_home are not marked as installed by TruffleRuby (they could belong to another Ruby implementation and break unexpectedly)

but unfortunately it would be shown after the error here.

I'll see what we can do to make it more resilient and if possible warn earlier.

FYI: The 20.2.0 installer is working fine with removing fileutils and stringio from GEM_HOME on my environment.

I'm fixing this in 3 ways:

  • Improve reliability of the post install hook by disabling RubyGems
  • Verify that gem paths are correct before loading RubyGems
  • Skip upgraded default gems while loading RubyGems.

    • Essentially, upgraded default gems do not work if RubyGems require the same library itself before doing the setup for default gems.

Fixed in 80abcaa07ac2f81633275c8356b1e9f99a0c8de3.

Was this page helpful?
0 / 5 - 0 ratings