Ubuntu Intrepid - Ruby on Rails

In the Ubuntu Intrepid setup articles (page 1 and page 2) we secured, updated and personalised the install ready to add some working software.

We also installed the build-essential package. Now we can go ahead and install Ruby on Rails.


This articles has been updated to use the latest (at the time of writing) version of rubygems which is v1.3.1.


The process will involve a mix of installation methods - the main ruby packages and dependencies will be installed using the 'aptitude' package manager but rubygems will be install from source.

The reason for this is that it is important to get the latest and most stable version of rubygems onto the Slice and the easiest way to do that is by installing from source.


Let's go ahead and install ruby. Note the install command shown below includes the sqlite3 db package.

Rails version 2.0+ uses sqlite3 as its default database - you can, of course, use other databases and indeed, there will be articles specifically aimed at other databases.

However, for now, we'll stick to the basics and get the main Ruby on Rails packages installed:

sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8


We need to create some symlinks from the install to locations every programme would look:

sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/bin/irb


Once done, we can have a look at the Ruby version:

ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]

Good, now we can move onto installing rubygems for our Rails installation.


As mentioned, we're going to install rubygems from source.


Let's go ahead and download the source code into our sources directory. If you haven't got a sources directory, you can simply create one:

mkdir ~/sources
cd ~/sources

At the time of writing the latest rubygems version is v1.3.1.

As normal, please check for the latest release on the rubygems homepage.

Let's download v1.3.1:

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz

Now unpack it and move into the newly created folder:

tar xzvf rubygems-1.3.1.tgz
cd  rubygems-1.3.1

Now we can go through the simple process of compiling it and creating a symlink:

sudo ruby setup.rb

The compile and install process will take a minute or two to run, and when it's finished you should see the following displayed at the bottom of the output text:

RubyGems installed the following executables:

If `gem` was installed by a previous RubyGems installation, you may need
to remove it by hand.

Let's create another symlink:

sudo ln -s /usr/bin/gem1.8 /usr/bin/gem


Once done, we can check the gem version with a:

gem -v



We need to do a quick update to rubygems:

sudo gem update

Although nothing will change as we have installed the latest version, a '--system' update will ensure everything is the latest and greatest:

sudo gem update --system


Continuing with the Rails installation, we can go ahead and install it:

sudo gem install rails

It may take a few minutes to run, and once completed, you can check what gems were installed with a:

sudo gem list

Which gives the following (from a fresh Slice and no other gems installed):

*** LOCAL GEMS ***

actionmailer (2.2.2)
actionpack (2.2.2)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (2.2.2)
rails (2.2.2)
rake (0.8.3)


sqlite3 test

Now we can do a simple test to see if the sqlite3 module is working:

irb(main):001:0> require 'sqlite3'
=> true
irb(main):002:0> exit

If the result does not return 'true' the you may have missed a step.

Postfix and subversion

Finally, we need to install postfix and subversion so we can 'check-out' plugins and send mail from our Rails applications:

sudo aptitude install postfix subversion -y

Answer the postfix questions as you see fit but the defaults usually suffice for our purposes as we are only using it to send emails and not for receiving mail.

That's it

You now have a Ruby on Rails and postfix/subversion stack setup and ready to roll.

Now you are ready to install the server of your choice whether that be Litespeed, Nginx or Apache.


Article Comments:

Anonymously Appreciative commented Sat Jan 17 23:07:37 UTC 2009:

Thanks! On Intrepid, I was following the typical 'apt-get' and 'gem install' path, and when I got to rails, it looked as if it had worked, but when I tried to run 'rails -v', all I wound up with was "rails not found". Followed your instructions and everything worked like a charm.

Tom commented Fri Feb 06 13:00:05 UTC 2009:

Worth noting that if you are having trouble with installing sqlite 1.2.4 against ruby enterprise (and gem in general) you need to install the sqlite dev package;

sudo aptitude install libsqlite3-dev

Iļja commented Mon Feb 16 22:47:13 UTC 2009:

Thank you very, very much.

Luciano commented Sun Feb 22 14:05:29 UTC 2009:

Great article :)

So clear, so efficient. Thanks you a lot !

Regards from France...

Yamaplos commented Sat Feb 28 22:55:37 UTC 2009:

OK, so I installed all of the above. What next? How do I get to a "hello world"?

RoR is the hardest ever I've come across in simply getting it together. And I am a veteran of Cinelerra and Rosegarden...

Jones Lee commented Mon Mar 02 23:40:55 UTC 2009:

Thanks mate, this article is very useful. I'd like to ask is there much difference between the Debian package and gem package version? Should I wait for Ubuntu to upgrade the gem/rake/rails? (in term of security concern)

Emmanuel commented Fri Mar 06 22:06:42 UTC 2009:


Emmanuel commented Fri Mar 06 22:11:32 UTC 2009:

Hi, First, Mike your article 's great. Thanks you. During installation i've some failures. I don't known what my mistakes. After installation of rubygem (by tarball + ruby setup.rb), i can't install any packages gem. To debug i use: gem install --debug rails-2.2.2. And i have lots of exeption: exception 'NameError' at ../1.8/rubygems command_manager.rb:134 - uninitialized constant. Can you help me to debug my installation ? I proceed in a local installation. Thanks.

Emmanuel commented Mon Mar 09 19:05:15 UTC 2009:

Hi, I solved mu problem. I've not installed :gem install update-rubgygems 1.3.1 Thanks for this excellent doc. Best regards.

Todd commented Mon Mar 23 07:48:54 UTC 2009:

Everything worked for me but installing rails. I needed to install rake first "sudo gem install rake"

Jonathan commented Sat May 09 16:55:24 UTC 2009:

great stuff. can't wait to read more of your tutorials.

Francis Fish commented Sun Jun 28 10:10:58 UTC 2009:

If nothing works or you get 404's update your aptitude repositories first with update aptitude.

Serg commented Mon Aug 31 16:04:01 UTC 2009:

Great work! It took me 10 min to install everything. Thank you!

Nick Pearson commented Sun Sep 06 14:40:59 UTC 2009:

Thanks for the clear walk-through.

I haven't needed to do this on previous Slicehost Ubuntu installs, but this time I had to install mailutils in order to get the /usr/bin/mail command, which I use to send myself cron job output.

sudo aptitude install mailutils

By the way, this was for Ubunty Jaunty (9.04) rather than Intrepid. (There are no Jaunty articles yet, which is why I'm commenting on this here.)

matt commented Fri Sep 18 16:21:40 UTC 2009:

After installing postfix, I keep getting this annoying "You have new mail in /var/mail/[username]". How do I turn this OFF! It keeps filling up that mail file with useless info after almost every terminal command.

Sean S commented Mon Nov 08 13:15:18 UTC 2010:

I've gone through this a bunch of times now (on ubuntu10)

Following this, you always try to create an app. (ex: rails new test_app) then you go into that dir and run, 'rails server'

it'll typically complain about sqlite3-ruby and say to 'bundle install'

this (at least for me) usually fails on sqlite3

naturally you'd respond with 'apt-get install sqlite3'.

This unfortunately doesn't have a recent enough version (bummer), and bundle install still fails.

The solution I found was 'apt-get install libsqlite3-dev' instead of 'apt-get install sqlite3'

This then allows 'bundle install' to work for sqlite3-ruby (hurray)

and 'rails server' will work.

(specs: from an empty slice, ubuntu10, with build-essentials installed)

ruby on rails developer uk commented Fri Aug 01 16:56:47 UTC 2014:

What's up i am kavin, its my first occasion to commenting anywhere, when i read this piece of writing i thought i could also make comment due to this sensible piece of writing.

Want to comment?

(not made public)


(use plain text or Markdown syntax)