Rbenv
Manage your ruby version
Rbenv
is a ruby version management tool that allows you to handle several versions of ruby on a same machine. Combined with ruby-build
, it also allows to install a given ruby version.
Installation
On MacOS, Rbenv
can be installed using homebrew. It comes by default with ruby-build included.
$ brew install rbenv
Then init your rbenv environment:
$ rbenv init
Usage
Install a given ruby version
# list all available versions:
$ rbenv install -l
# install a Ruby version:
$ rbenv install 2.0.0-p247
Set the global ruby version
The version that will be used by default in your shell if no local version is specified.
$ rbenv global 1.8.7-p352
This will define the ruby version in ~/.rbenv/version
.
Use a local ruby version
A version that will be used in a given directory/for a given project can be installed like this:
# in the directory you want to use the local ruby version
$ rbenv local 1.9.3-p327
The ruby version is defined in a .ruby-version
file in the given directory. Therefore, sharing a git repo with a .ruby-version
file in the root directory will automatically set the ruby version used for the project.
Useful commands
# List all known ruby-versions (installed ones are marked by an asterisk)
$ rbenv versions
# Show the currently used ruby version
$ rbenv version
Last updated
Was this helpful?