Install Ruby 2.1.0 and Ruby on Rails 4.0.2 on Ubuntu 12.04 LTS

Ruby Rails is a Web application framework created in 2004 intended as a rapid development web framework that runs the Ruby programing language. The latest version of the Ruby is ‘Ruby 2.1.0‘ and was released in December 2013, it brings many new features and bug fixeses. This tutorial will guide you through the installation of the latest version of ruby and rail as I’m sure you want to be working with the latest version of Ruby and RubyonRails, especially if you setting up a new server.

Well if your using Ubuntu you can setup Ruby and RubyonRails quickly using the supplied repository’s, a good tutorial for this can be found here. However this is not recommended as the Ubuntu repositories are often out of date and if you install ruby or rails via the repository’s it can be pain to upgrade. So in this guide we are going to go through installing RVM (this allows you to install, change and upgrade the installed Ruby version), Ruby 2.1.0 and Rails 4.0.2 This Guide has been tested on Ubuntu 11.10 however it should work on all versions of Ubuntu later then Ubuntu 9.04.

First of all you’ll need to install some packages that Ruby, RVM and RubyOnRails will require later, the easiest way to do this is using the repositories so go to your terminal and type:

sudo apt-get update
sudo apt-get install build-essential git-core curl libmysqlclient18 nodejs

Now let’s install the latest version of RVM using curl:

\curl -sSL | bash -s stable

Now you’ll need to ask RVM if it needs any more programs and if so you’ll need to install them to do this type:

rvm requirements

Two things could happen here if you see the following message saying you need to install ‘rvm‘, ignore this it and restart your terminal, this should fix the problem.

The program 'rvm' is currently not installed.  You can install it by typing:
sudo apt-get install ruby-rvm

You should see something that looks like this after you restart your terminal:

You will be required to enter your password, after this RVM will automatically install any required packages.


Before completing this step I would recomend restarting your console otherwise you may run into problems. Once you have installed all these packages its time to install Ruby 2.1.0 herself. The following command will install Ruby 2.1.0.using the rmv package. However this can take a few minutes (15 in my case) to install so I recommend getting a drink, or my favourite, a pizza 😆 .

rvm install ruby


You can test that Ruby is installed correctly and running at version 1.9.2 by typing

ruby -v

This should output something like “ruby 2.1.0P0” showing you that version 2.1.0 is installed and is now the default Ruby version.

The nice thing about RVM is you can use it to install any version of Ruby and switch between the versions your have installed, to do this just enter “rvm install [Version Number]” then “rvm –default use [Version Number”, you can then use “rvm –default use” to change to any installed version.

Now that you have the latest version of ruby installed I’m sure you want to get the latest version of Rails installed, at the time of writing this tutorial that’s Rails 4.0.2. To install Rails we can use GEM which is installed along with RVM and Ruby, to install the latest version of Rails just type, (this can take also take a while):

gem install rails

And that’s it you have now installed RVM, Ruby 2.1.0 and Rails 4.0.2 on Ubuntu 12.04LTS configured to use sqlite3, you can now setup your new Rails package with

rails new [project name]

Just as a final note, If you want to use MySQL instead of sqlite3 you’ll need to enter the following

sudo apt-get install mysql-server
gem install mysql2
rails new [project name] -d mysql

Comments are closed.