LinuxCommandLibrary

chruby

Change current Ruby version

SYNOPSIS

chruby [RUBY_ENGINE-]RUBY_VERSION[@GEMSET] | -l | -p | -u | -v | -h

PARAMETERS

-l, --list
    List all available Ruby versions from configured directories.

-p, --print
    Print the full path to the currently active Ruby.

-u, --unset
    Remove current Ruby from PATH (deactivates it).

-v, --version
    Print the chruby version and exit.

-h, --help
    Display usage summary and options.

DESCRIPTION

Chruby is a minimalist, fast Ruby version manager designed for Unix shells like bash and zsh. It manages multiple Ruby installations by dynamically adjusting the PATH environment variable, without shims, wrappers, or shell modifications. Users install Rubies (compiled or from packages) into directories like $HOME/.rubies or /opt/rubies, named by version (e.g., ruby-3.1.2).

Invoke chruby 3.1.2 to activate a version; it prepends the Ruby's bin directory to PATH and sets GEM_HOME, GEM_PATH. Supports gemsets via ruby-3.1.2@gemset. Use auto-switching by placing .ruby-version files in project directories.

Unlike RVM or rbenv, chruby is a tiny POSIX shell script (<300 lines), unintrusive, and blazing fast. Source its init script (e.g., in ~/.bashrc) for integration. Ideal for developers seeking simplicity and performance in multi-Ruby workflows.

CAVEATS

Must source init script (e.g., ~/.bashrc.d/chruby.sh) per shell session. Rubies must be pre-installed; no built-in compiler. Relies on CHRUBY_DIRS env var for paths. Limited shell support (bash/zsh primary; fish via plugin).

AUTO-SWITCHING

Enable with ~/.bashrc.d/auto-chruby.sh; detects .ruby-version files on cd.

CONFIGURATION

Set CHRUBY_DIRS (e.g., export CHRUBY_DIRS=$HOME/.rubies:/opt/rubies) to customize search paths.

HISTORY

Created by Postmodern (Travis Furrer) in 2012 as a POSIX-compliant alternative to RVM's complexity. Gained popularity for speed/simplicity. Maintained on GitHub; latest releases enhance gemset handling and directory scanning.

SEE ALSO

rbenv(1), rvm(1), asdf(1), ruby(1)

Copied to clipboard