How to use RVM
Ruby Version Manager (RVM) is a way to mange multiple version of ruby on the same computer. It is somehow similar to python’s virtualenvs, but has more features, like:
- list, download and install desired ruby version
- automatically switch to proper version when one enters a project’s directory
- etc.
Installation
Is quite easy: see https://rvm.io/.
For Mac additionally we have to install gnupg
by calling:
(then use gpg
insted of gpg2
)
and for Ubuntu:
Then add the following lines to .zshrc
(or .bash_profile
or .bashrc
):
export PATH="$PATH:$HOME/.rvm/bin"
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Usage
If you get, Warning! PATH is not properly set up, … you can try to run:
rvm reset
In order to install a MRI version (Matz’s Ruby Interpreter, the original version used by most people) you can type, for example,
or simply
In order to use it, type:
If you want to come back to the system version type:
ruby-version
One can make use rvm to automatically switch between ruby version. Let’s say we have created a
project called bartek-blog
.
Then we have to enter the directory of the project.
And run the following lines:
This will create files .ruby-gemset
and .ruby-version
. Now each time ones enter the directory
rvm
with switch to the desired version of ruby automatically.
Updated: 2020-12-10