Browse Articles in Ruby
Andre Honsberg Andre Honsberg is a software engineer who develops mostly for the Web. He lives in Hamburg Germany and works building software for the web using a wide spectrum of different technologies.

alt textIn this article I will explain how you can get RVM (Ruby Version Manager) installed on Ubuntu 12.04 Linux. First we have to make sure that we have some dependencies installed, so run the following command to take care of them.

sudo apt-get install build-essential git-core

Now we need to install RVM (Ruby Version Manager) using curl. If you do not have curl installed yet on your system, you can issue the following command

sudo apt-get install curl

To start the RVM installation run the following command

bash -s stable < <(curl -s

Now we need to add a line to our bashrc file so run the following command

echo '[[ -s "/home/andre/.rvm/scripts/rvm" ]] && source "/home/andre/.rvm/scripts/rvm"' >> ~/.bashrc

Make sure to replace andre with your user name in the above command so that you will not have any issues on your system. Now run

source ~/.bashrc

To test if our installation of RVM was succesfull, we can run a command and check its output.

type rvm | head -1

If the output of the above command is equivalent to rvm is a function, then we now have a working RVM installation. Now our Ruby Version Manager is installed and we can go ahead and install all the Rubies we want. To extend this article a little more I will go over how to install an actual Ruby version and also a Ruby Gem. So here we go...

rvm install 1.9.3

The above command will install Ruby version 1.9.3 under your .rvm directory. To make the Ruby the default one we run

rvm use --default 1.9.3

Now let us install the Ruby Gem Mysql2 which is needed for mostly everything I do. It may be possible that we need some dependencies depending on your system. On my Ubuntu 12.04 installation I did not need to install the dependencies but have seen it in the wild being asked so this command might save you some headaches...

sudo apt-get install mysql-client mysql-server libmysql-ruby libmysqlclient-dev

To install the Ruby Gem Mysql2 run the following command in you Ubuntu 12.04 installation

rvm 1.9.3 do gem install mysql2

If you installed Ruby 1.9.3 then the command to install Mysql2 will be exactly like above. If you used a different version of Ruby then make sure you put the version or full Ruby name and replace 1.9.3 above with your needs.

If you need to fall back to your system's Ruby that might have been pre-installed you can use the following command:

rvm use system


To have your terminal behave properly with Ubuntu 12.04 after you reboot we need to set the

> Run command as login shell

setting. To do that open up a terminal by pressing CTRL+ALT+t. Once your terminal is open, right click the terminal, and click on Profiles then Profile Preferences.

Now click on the Title and Command tab. Check Run command as a login shell. Now close the window.

Now we need to do one more thing. Run the following command in the terminal:

gedit ~/.bash_profile

This will open a text editor where we will add the following two lines:

source ~/.profile
source ~/.bashrc

The reason this works is because we told the terminal to start as a login shell. This fixes an issue with RVM that happens when the terminal can't recognize RVM.

Want to leave a Commnet?
Sunday the 16th of June, 2013 at 08:02:44
Gravatr Image
Andre, thanks for the guidance. I fear I'm quite new to all this, but was able to get through all of it until I tried adding those two lines to bash_profile. Even though I am the only user on this OS, I didn't have permission to save edits to the file (even after su and have the terminal act as a login shell). Is there a straight forward way to correct this or what is the best resource for figuring out the solution. The resources I've read so far haven't got me there.
Andre Honsberg
Monday the 17th of June, 2013 at 21:06:34
Gravatr Image
Did you replace "andre" with your username?
Friday the 28th of June, 2013 at 13:07:45
Gravatr Image
I have install RVM successful but at first time I forgot to change the user name and run comment with Ander and run second comment that give.

vinod@vinod-HP-Pavilion-Sleekbook-14:~$ source ~/.bashrc

bash: /home/andre/.rvm/scripts/rvm: No such file or directory

bash: /home/andre/.rvm/scripts/rvm: No such file or directory

bash: /home/andre/.rvm/scripts/rvm: No such file or directory

After that I change the user name and run commend but it give same error that not find the location.

vinod@vinod-HP-Pavilion-Sleekbook-14:~$ echo '[[ -s "/home/vinod/.rvm/scripts/rvm" ]] && source "/home/vinod/.rvm/scripts/rvm"' >> ~/.bashrc

vinod@vinod-HP-Pavilion-Sleekbook-14:~$ source ~/.bashrc

bash: /home/andre/.rvm/scripts/rvm: No such file or directory

bash: /home/andre/.rvm/scripts/rvm: No such file or directory

bash: /home/andre/.rvm/scripts/rvm: No such file or directory

Please Help me

Andre Honsberg
Friday the 28th of June, 2013 at 13:13:07
Gravatr Image
ok run at the command line: nano ~/.bashrc then in the editor go to the bottom and delete the line /home/andre/.rvm/scripts/rvm then press [ctrl][x] and hit y for yes the run: source ~/.bashrc
Tuesday the 30th of July, 2013 at 05:43:38
Gravatr Image
I just wanted to say how much I appreciate your help with rvm

Thanks again,

Tuesday the 1st of October, 2013 at 16:02:10
Gravatr Image
Thanks Andre, after trying to set this up for the past day your tut solve it the most valuable is the ability to start rvm on terminal start. I have one request though, "configuring a MongoDB environment with Rails 4". Thanks