Setting up Ruby 1.9.2 and Rails 3.0.9 using RVM
Ruby Version Manager (rvm) is a shell function that lets you easily switch between versions of ruby (and their corresponding gems). These instructions walk you through installing rvm, ruby, and rails on linux for a single-user setup (files kept in ~/.rvm). Following these instructions as root should set everything up for a multi-user installation.
Dependencies
Make sure you have curl and gcc installed. In debian-based distributions, you can install thiese with:
sudo apt-get install build-essentials curl
Installing RVM
Get the installation script and run it
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
When the installation script finishes, it should add a line to your ~/.bashrc or ~/.bash_profile. If not, you can add this line to the end of your .bashrc or .bash_profile:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
If you want tab-completion with rvm, you can add this line to your .bashrc or .bash_profile file too:
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion #rvm tab completion
To use rvm, you can close and reopen the terminal or source ~/.rvm/scripts/rvm
Install Ruby 1.9.2
Let’s install ruby 1.9.2 and set it as the default ruby interpreter:
rvm install 1.9.2; rvm --default use 1.9.2
You can see what other versions are ruby are available with
rvm list known
You can revert to using the ruby interpreter installed on the system
rvm system
And have your terminal use the system ruby interpreter by default
rvm --default system
RVM Gemsets
RVM lets you have separate sets of gems that can be combined with the different ruby installations. This lets you switch, for example, between different versions of rails depending on the project you want to work on.
Create a Gemset and Install Rails 3.0.9
rvm gemset create rails309
rvm 1.9.2@rails309
gem install rails -v 3.0.9
Tada!
You can now work with a Ruby on Rails project and easily switch between Ruby and Rails versions.