Meet Our Clients

Have a project and need some help?

Give us a shout and we’ll get back to you quick, fast, and in a hurry.

The Perfect Rails Install on Ubuntu 11.10

Posted on February 6th, 2012 by Damon Morda
The Perfect Rails Install on Ubuntu 11.10

I’ll admit, I enjoy programming in Ruby on Rails. It’s the perfect fit for so many of my smaller projects where I need to build a small application and have it up and running quickly. However, sometimes it can be extremely frustrating to install a new system with the right versions of Rails, Ruby, MySQL, etc. Often times the distribution may have older packages or the gems are picky about what version of libraries are installed on the system. Well, if you run Ubuntu 11.10, this post is for you as it will outline a cut and paste set of commands to get you up and running with Ruby 1.92, Rails 3.20, Rubygems 1.8.15, MySQL and SQLite.


This guide outlines a procedure for installing the following Rails environment:

  • Ubuntu 11.10
  • Ruby 1.92
  • Rails 3.20
  • Rubygems 1.8.15
  • MySQL
  • SQLite
  • Git

Step 1: Update your operating system packages

The first thing we are going to do is get the latest updates for Ubuntu. The following two commands will download and install the latest Ubuntu updates.

sudo apt-get update
sudo apt-get upgrade

Step 2: Install Ruby 1.9.2, build-essential, and git

Ubuntu provides several versions of Ruby. If you aren’t careful, you may end up installing older or even multiple versions. We want to install version 1.9.2 so we have the latest and greatest. For this, and other tasks ahead of us, we’ll also need build-essential as it has the developer tools that will be needed to compile various gems. Git is optional, but it doesn’t hurt to have a handy version control system at your disposal.

sudo apt-get install ruby1.9.2-full build-essential git-core

Step 3: Install RubyGems 1.8.15

Ubuntu is a few versions behind on their offical RubyGems package. So rather than using that we’ll use the RubyGems installation method here. You’ll download version 1.8.15 of RubyGems, unzip it, and then run the setup.rb program to install it.

tar -zxvf rubygems-1.8.15.tgz
cd rubygems-1.8.15
sudo ruby setup.rb

Step 4: Update RubyGems

Once you have RubyGems installed, you want to double-check to make sure you have the latest version of the RubyGems software and then update all gems, if you have any installed.

sudo gem update --system
sudo gem install rubygems-update
sudo update_rubygems

Step 5: Install everything else

Now that you have RubyGems installed, it’s time to install Rails and the rest of the gang. One of the common issues I’ve run into when installing Rails is that I’d get compile errors when installing MySQL or SQLite. We’ll address that by installing the the right Ubuntu packages. I’ve also run into the occasional error when running commands to generate new models, controllers, etc. We’ll fix that by installing node.js as the JavaScript framework.

sudo gem install rails
sudo apt-get install libsqlite3-dev
sudo gem install sqlite3
sudo apt-get install nodejs
sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql

Step 6: Test Drive

You should now have a working Ruby on Rails environment. To test it out, create a Rails application in your home directory as follows:

cd ~/
rails new app_of_the_century
cd app_of_the_century
rails generate model User

If you installation worked, Rails should create your application file/folder structure and generate a User model all without a single error.

Cut and Paste Version

Now that I’ve explained it step-by-step above, here’s a cut and paste version that should “just work” if you were to paste it into a terminal window.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install ruby1.9.2-full build-essential git-core
tar -zxvf rubygems-1.8.15.tgz
cd rubygems-1.8.15
sudo ruby setup.rb
sudo gem update --system
sudo gem install rubygems-update
sudo update_rubygems
sudo gem install rails
sudo apt-get install libsqlite3-dev
sudo gem install sqlite3
sudo apt-get install nodejs
sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo gem install mysql

I certainly appreciate feedback so if you have other suggestions for a smoother Rails install on Ubuntu 11.10, add a comment to the post so that I can improve this post. Thanks in advance!

22 Responses

    Ste February 22, 2012 at 10:01 am

    Thank you sir. Have tried many ‘simple step’ solutions to get ruby on rails working on Ubuntu 11.10, yours is the only one that has worked.

    Much appreciation.

    Vic March 3, 2012 at 2:13 pm

    I’m pretty old now, and am getting back into programming after a break of some 20 years. I settled on ruby because I maintain a couple of web sites so it seemed to be a relevant language. I was fortunate to happen on your blog because it afforded a beautifully crafted walk through of the setting up process and it could not have gone more smoothly, so many thanks indeed for all your work and care: I do appreciate it.

    Tuan Jinn March 5, 2012 at 1:51 pm

    Thank you. Your solution was the only one that gets me where I expected my setup to run.

    Walter March 6, 2012 at 7:37 pm

    I am shocked! The steps worked the first time, no fuss, no muss.

    Very nice!

    Damon Morda March 6, 2012 at 7:40 pm

    I know I struggled the first few times trying to get the steps correct. Then after a few tries, I was able to get a repeatable set of steps and decided to share it with others.

    Glad to hear the walkthrough is working for everyone.

    imwilsonxu March 9, 2012 at 2:45 am

    Pls note that:

    Hello! The sqlite3-ruby gem has changed it’s name to just sqlite3. Rather than installing `sqlite3-ruby`, you should install `sqlite3`. Please update your dependencies accordingly.

    So pls replace

    sudo gem install sqlite3-ruby


    sudo gem install sqlite3

    Damon Morda March 11, 2012 at 12:32 pm

    Thanks for the suggestion, I’ve updated the post to reference it as sqlite3 rather than sqlite3-ruby.

    rk_1972 March 14, 2012 at 2:06 pm

    Excellent, Installed without a problem. Awesome work. Keep it up.

    Jim March 20, 2012 at 3:54 pm

    Do you know how to force apt-get to install ruby 1.9.3. My system keeps installing v. 1.9.1 even when I tell it v. 1.9.2. Would using something like “aptitude install” work?

    Also, when I look at “ruby -v” it’s telling me I’m running two versions of ruby and it can’t seem to determine which one to use. Any thoughts on how to fix?

    Man I wish I found your blog before I started using the mish-mash of instructions out on the interwebs. I think I fracked my computer a bit.

    adred March 26, 2012 at 2:11 am

    Works like charm. Thanks!

    adred March 26, 2012 at 2:12 am

    It installed 1.9.1 instead, but it’s okay! =)

    Ashraf Sarhan April 2, 2012 at 9:05 pm

    Thanks so much, it’s a very knowledgeable. i wanna make some help for those people who can not install ruby 1.9.2, you can solve this problem by issuing the following command line in your terminal:
    sudo add-apt-repository ppa:ubuntu-on-rails/ppa
    sudo apt-get update
    sudo apt-get install ruby1.9.2-full build-essential git-core
    Hopefully, Damon Morda update the third command by this one
    Thanks :)

    AsanaWest April 4, 2012 at 2:26 pm

    Best (non RVM) ROR installation tutorial in the sky

    Pablo April 17, 2012 at 1:21 pm

    Thanks for your great help!

    Sumukh April 18, 2012 at 5:07 am

    This was really good. I just had to include –http-proxy=http://host:port while using sudo gem install … or sudo gem update … commands.

    Thanks a ton for the crisp steps !!!

    Justin Boucher April 19, 2012 at 9:09 am

    Tutorial worked great (although it still installed Ruby 1.91). I also decided to expand it a little with adding Subversion as a Team Server. I am more familiar with subversion, and wanted to continue down that path for my test server. I wrote a shell script to auto-magically install and configure everything, including subversion at:

    Gave Damon Morda the shoutout he deserves as well.

    Damon Morda April 19, 2012 at 8:04 pm

    Great write up Justin and thanks for the shout out!

    David G April 21, 2012 at 12:32 pm

    Thanks for the only guide that works =)

    Anthony C May 19, 2012 at 2:08 pm

    Two things:

    1) Awesome tutorial. I really appreciate the simple and easy instructions all compiled in one place.

    2) I did run into a problem when trying “sudo ruby setup.rb” I was getting an error saying ruby command not found.

    I had to do some searching and found that typing this line got things working:

    sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby

    That allowed me to rerun sudo ruby setup.rb without problems and move on through your instructions.

    Just figured I’d add what I found in case the next guy runs into my same problem.

    vinay g raj June 4, 2012 at 10:26 am

    oh this works great !! finally…

    thanks a lot..

    Tony June 4, 2012 at 3:22 pm

    You guys rock! I’m a Windows/.NET guy and a Ubuntu/rails noob and I spent hours on this before I came across your post and it worked first time through.

    baash05 June 4, 2012 at 10:17 pm

    I ran through this and then attempted to build the app_of_the_century. I got no joy.
    ‘to_spec’ : could not find railties.
    So I ran gem list
    The list was empty. Should it be?