Ruby rbenv
rbenv is for managing 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
Run executables with selected ruby version (by .ruby-version
or global)
- Help doc
$ rbenv help exec
Usage: rbenv exec <command> [arg1 arg2...]
Runs an executable by first preparing PATH so that the selected Ruby
version's `bin' directory is at the front.
For example, if the currently selected Ruby version is 1.9.3-p327:
rbenv exec bundle install
is equivalent to:
PATH="$RBENV_ROOT/versions/1.9.3-p327/bin:$PATH" bundle install
- Install gem to selected ruby version
$ rbenv exec gem install rails
See official docs for more.
TOP▲