chruby

Lightweight Ruby version switcher

TLDR

List available Ruby versions
$ chruby
Switch to specific Ruby
$ chruby ruby-3.2.0
Switch to system Ruby
$ chruby system
Show current Ruby
$ chruby | grep '\*'

SYNOPSIS

chruby [rubyversion_ | system]

DESCRIPTION

chruby switches between multiple Ruby versions by modifying PATH and related environment variables. Lightweight alternative to RVM and rbenv. Just 90 lines of shell script.Works with rubies installed by ruby-install or built from source.

SETUP

Add to ~/.bashrc or ~/.zshrc:

$ source /usr/local/share/chruby/chruby.sh
For auto-switching:
$ source /usr/local/share/chruby/auto.sh

AUTO-SWITCHING

With auto.sh loaded, chruby reads .ruby-version files:

$ echo "ruby-3.2.0" > .ruby-version
Checks current and parent directories automatically.

DEFAULT VERSION

Set in ~/.bashrc or ~/.zshrc:

$ chruby ruby-3.2.0

ENVIRONMENT

RUBIES

Array of Ruby installation paths
RUBY_ROOT
Current Ruby installation path
GEM_HOME / GEM_PATH
Gem directories

INSTALL

brew install chruby
nix profile install nixpkgs#chruby

CAVEATS

Only switches versions - use ruby-install to install rubies. Does not override cd command (uses pre-prompt hook).

SEE ALSO

rbenv(1), rvm(1)