RVM or Ruby Verion Management is a library written for managing multiple version of Ruby on a single machine, and even for a single user. Using this set of libraries you can easily install a version of Ruby and switch between different version as and when you see fit. This is great for developers, especially those having to maintain multiple different applications, using different Ruby and potentially rails versions.
Installation of RVM on Ubuntu 12.04 for a single user
To start, download RVM and automatically install the latest stable version of Ruby
curl -L https://get.rvm.io | bash -s stable --ruby
Here we download a file which has a series of commands for installing RVM and the latest stable version of Ruby. `-s` tells bash to read commands from the standard input, which is the downloaded file from the rvm website. This process will take a while, depending on your connection speed and processors as it downloads and compiles Ruby and Rubygems.
Once installed, running the following command will allow rvm to be available in your current session. If this does not work simply restart your shell.
Now ensure the Ruby version downloaded is in use, to do this tell RVM To use the version number. In my case 2.0.0 has been installed:
rvm use 2.0.0
Now check your Ruby version:
ruby -v > ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
Perfect, gems will also be the relevant bersion
gem -v > 2.0.3
To install another version of Ruby simply run the following command, where
rvm install <version>
rvm install 1.9.2
Then tell RVM to use this version:
rvm use 1.9.2 ruby -v > ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
That’s it, you can now use either version, or any other version available.
If you are upgrading an existing rails application to use another version of Ruby (in my case 2.0.0), remember to run bundle update.