rbenv is a great tool to manage multiple Ruby versions and here are some of its commonly used commands summarized for quick reference.

Install rbenv itself and setup

$ brew install rbenv
$ rbenv init # follow the printed instruction and add below entry to ~/.bash_profile
$ eval "$(rbenv init -)"

Install/Uninstall ruby versions

$ rbenv install -l # list all available versions
$ rbenv install <version> # install a specific version
$ rbenv version # show the current version in use
$ rbenv versions # list all installed versions (can also check ~/.rbenv/versions/)
$ rbenv uninstall <version> # uninstall a specific version

Set/Unset ruby versions

$ rbenv local <version> # will add a .ruby-version file into current directory with version name to override the global version
$ rbenv local --unset # unset and remove the .ruby-version file

$ rbenv global <version> # will write to ~/.rbenv/version as global version but it can be overriden by the local one if set above

$ rbenv local # show the current local ruby version used
$ rbenv global # show the current global ruby version used

$ rbenv local system # set local version to current system Ruby ($PATH)
$ rbenv global system # set global version to current system Ruby ($PATH)

$ rbenv shell <version> # set RBENV_VERSION env to override both local/global version set above
$ rbenv shell --unset # unset the RBENV_VERSION env

See official docs for more.

Post tagged with: ruby