LinuxCommandLibrary

chruby

Lightweight Ruby version switcher

TLDR

List available Ruby versions

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

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
copy
For auto-switching:
$ source /usr/local/share/chruby/auto.sh
copy

AUTO-SWITCHING

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

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

DEFAULT VERSION

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

$ chruby ruby-3.2.0
copy

ENVIRONMENT

RUBIES

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

CAVEATS

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

SEE ALSO

ruby-install(1), rbenv(1), rvm(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community