It's recommended to add TruffleRuby to a Ruby manager for ease of use. You will need to download and unpackage GraalVM manually. There is no support for automatically installing TruffleRuby in a version manager.
To add TruffleRuby to rbenv
a symbolic link has to be added to the versions
directory of rbenv:
$ ln -s path/to/graalvm/jre/languages/ruby "$RBENV_ROOT/versions/truffleruby"
$ rbenv shell truffleruby
$ ruby --version
To add TruffleRuby to chruby
a symbolic link has to be added to the
$HOME/.rubies
directory:
$ ln -s path/to/graalvm/jre/languages/ruby "$HOME/.rubies/truffleruby"
$ chruby truffleruby
$ ruby --version
RVM has a command for adding a precompiled Ruby to the list of available rubies.
$ rvm mount path/to/graalvm/jre/languages/ruby -n truffleruby
$ rvm use ext-truffleruby
$ ruby --version
Note that on macOS the path is slightly different, and will be
path/to/graalvm/Contents/Home/jre/languages/ruby
.
If you are using a Ruby manager like rvm
, rbenv
, or chruby
and wish not to
add TruffleRuby to one of them make sure that the manager does not set
environment variables GEM_HOME
, GEM_PATH
, and GEM_ROOT
. The variables
are picked up by TruffleRuby (as any other Ruby implementation would do)
causing TruffleRuby to pickup the wrong Gem home instead of its own.
One way to fix this for all sessions is to tell TruffleRuby to ignore GEM_*
variables and always use its own Gem home under truffleruby/lib/ruby/gems
:
# In ~/.bashrc or ~/.zshenv
$ export TRUFFLERUBY_RESILIENT_GEM_HOME=true
It can also be fixed just for the current terminal by clearing the environment with one of the following commands:
$ rvm use system
$ rbenv system
$ chruby system
# Or manually:
$ unset GEM_HOME GEM_PATH GEM_ROOT