Installing ruby on Linux is easy, just run
sudo apt-get install ruby or
yum install ruby. However, version control can be difficult to manage. That is, scripts that run on a version on your computer may not run as well on another. So wouldn’t it be great if you could have 2 or more versions or the ruby interpreter on your computer.
To do this we will use the RVM – Ruby Version Manager. This is a great program, Allowing you to have complete environments for running ruby. This includes the interpreter and gems. And besides the few intricacies of setting it up, It is relatively easy to do.
OK. Lets go..
Firstly make sure that you have a version ruby installed and curl for downloading the script (most distributions come standard with this, although minimal setups will not.
sudo apt-get install ruby curl
yum install ruby curl
Now make sure that you are logged in as the user that you want to install ruby for. This may be a no brainier however, if you have more than one user you may wish to install ruby for everyone or for a specific person. I would very much suggest NOT install RVM for everybody, because different users may choose to run different ruby interpreters which may cause problems latter on down the track.
Time to get dirty with the command line.
Open up a terminal session and cd to your home directory. The first thing is to download the install script and run it in bash
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Once the script has run issue the following command to load RVM every time you login.
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
Now you need to close all your open terminal windows and then launch another. When the new one is open execute the following.
Now, to test that we have done all the previous correctly you need to use the following command and compare the results.
type rvm | head -l
The should output
'rvm is a function'
Thats it. Ruby Version Manager has been installed. Unfortunately, just having it installed is not much good, we need to look at gemsets and ruby versions, but that is for another post.