3

Is there a way to select the default system-wide ruby through chruby?

Eg:

$ which ruby
/usr/bin/ruby
Tom Hale
  • 40,825
  • 36
  • 187
  • 242

1 Answers1

3

If you want to change back to the default system ruby, just use:

chruby system

If you have more than one system-installed ruby (eg /usr/bin/ruby and /usr/local/bin/ruby) and want to use a different one than is listed by which ruby, you can:

export RUBIES+=(/usr/local)

Then chruby will list usr/local as a "version" of ruby.

For the general case (possibly multiple rubies in the path), add the following to your shell startup:

export RUBIES+=( $(which --all --skip-alias --skip-functions --skip-dot --skip-tilde ruby | sed -n 's/\/bin\/ruby//gp' |sort -u) )
Tom Hale
  • 40,825
  • 36
  • 187
  • 242