RVM (Ruby Version Manager) is a command-line tool which allows you to manage a ruby environment handling multiple versions of your ruby interpreter and gems. It can upgrade and downgrade versions with almost no overhead. RVM is a community project and it’s located on Github at https://github.com/wayneeseguin/rvm.

Why use RVM?

If you are a ruby developer you may eventually have multiple projects in your development machine. Each project may use a different ruby interpreter version and it can have gems with different versions. RVM lets you deploy each project inside it’s own sandbox, using the exactly environment that is required to run it. It is helpful to avoid complex issues of conflicts between projects for using different versions.

If it is an open source project or a project that may run in multiple plataforms, RVM can be used to ensure that the application is compatible with different configurations, for example, using different versions of Rails or using the JRuby interpreter.

It’s also the easiest way to have your system running with the latest version of the ruby ecosystem since it’s really easy to upgrade version.

Installing RVM

I’m assuming you are using a Linux environment (OS X should also work). First of all, lets get the latest version of the RVM on Github using command-line (must have curl and git installed):

$ bash <

Don’t use sudo, this way RVM will be installed under your home directory, at ~/.rvm/

Now, we need to make it work in the shell as a regular command. We put it at our bash_profile using the following command:

$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

Now we just need to restart the terminal and find out if RVM is working. Lets try it:

$ rvm

If don’t see any error message, it means it is working fine.

Installing Ruby

First, lets see what’s avaible for us:

$ rvm list known

# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.6-head
[ruby-]1.8.7[-p352]
[ruby-]1.8.7-head
[ruby-]1.9.1-p378
[ruby-]1.9.1[-p431]
[ruby-]1.9.1-head
[ruby-]1.9.2-p180
[ruby-]1.9.2[-p290]
[ruby-]1.9.2-head
[ruby-]1.9.3-preview1
[ruby-]1.9.3-rc1
[ruby-]1.9.3[-p0]
[ruby-]1.9.3-head
ruby-head

[...]

In my case, I’m going to stick with 1.9.3. To install and use it, it is simple as the snippet below:

$ rvm install 1.9.3
$ rvm use 1.9.3

Voil√†, it’s ready to use.

$ ruby -v

ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

What’s next?

This tutorial is intended to be the minimum to get RVM up and running. For further information on basic and advanced topics, try: