Ruby on Rails

Setting Up Ubuntu 9.10 for Ruby On Rails Development

This is a document I put together at the beginning of 2010 while building yet another Ubuntu VM, digging through our internal documentation to try and find out what I needed. We've got the answers, and generally Ruby, Rails, and Ubuntu are pretty good about telling you how to install tools if you don't have them yet.

But the answers are spread out and distributed randomly. Plus, I can only see "The program '______' is currently not installed. You can install it by typing: sudo apt-get install ______" so many times before I lose interest and put off the task.

So, to prevent future headaches and help all of us out, I put together a how-to that can take a new Rails system from zero to code in a few minutes (depending on network speed) instead of half a day. With no further ado,

Setting up an Ubuntu box for Rails Development (including virtual machines)

Update everything

$ sudo aptitude update && sudo aptitude dist-upgrade

Install necessary packages

$ sudo aptitude install build-essential vim \
  vim-runtime git-core subversion libsqlite3-dev

We have projects in git (the newer ones) and svn, so we have to be able to switch fluidly between the two.

And I'm not trying to start a flame war, but Vim is the first choice for Rails development. You don't have to take my word for it; Jamis Buck, Tim Pope, and Adam Lowe all say the same. I recommend the NERDTree, FuzzyFinderTextMate, BufExplorer, and rails.vim plugins if nothing else.

Install ruby

$ sudo aptitude install ruby1.8 ruby rdoc ruby1.8-dev \
  libpgsql-ruby1.8 libmysql-ruby1.8 irb libopenssl-ruby

Get rubygems from source.

$ wget
$ tar xzvf rubygems-1.3.5.tgz
$ cd rubygems-1.3.5
$ sudo ruby setup.rb
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
$ sudo gem update --system

Update ~/.gemrc (at least the :sources: chunk)

gem: --no-ri --no-rdoc
:benchmark: false
:verbose: true
:backtrace: false
:update_sources: true

Install and setup Passenger (optional)

$ sudo apt-get install apache2-prefork-dev
$ sudo gem install passenger
$ sudo passenger-install-apache2-module

and follow the instructions passenger gives you. Most folks in the office run some form of an Apache-Passenger stack for development purposes. I can explain how that setup works in a future post.

Install geminstaller

$ sudo gem install geminstaller

Almost all of our legacy projects use geminstaller to manage gem dependencies. In the future, new projects will be moving to Bundler, but legacy projects matter and upgrading subsystems is not always justified.

"If it ain't broke, don't fix it" and the corollary: "because you probably won't be able to bill it to the client" both apply.

Install common packages (optional, may be required by projects)

$ sudo aptitude install imagemagick
$ sudo gem install utility_belt open_gem redgreen

The first (imagemagick) is used by the Paperclip gem to manage files attached to Rails models. The second are tools that make Rails development more manageable on the command line. I highly recommend them. Besides, I've been sneaking redgreen in as a test dependency on our projects, so if you're a developer here you'll have to install it anyways.

Create an ssh key (follow instructions)

$ ssh-keygen


All the stuff above won't let you test-code-deploy without hassles, so here's a sample run through of what the last mile of project-specific setup looks like.

Get the project. SVN, Git, whatever. Go to it.

$ svn co rails-project
$ cd rails-project

Run geminstaller

$ sudo geminstaller # normal
$ sudo geminstaller -c config/test/geminstaller.yml # test env

Install necessary aptitude packages

$ sudo aptitude install texlive-latex-base

Don't ask.

Create the test database


$ rake RAILS_ENV=test db:create

Postgres (using your username or DB username in place of "username"):

$ sudo -u postgres psql
postgres=# CREATE USER username SUPERUSER;
postgres=# CREATE DATABASE username OWNER username;

If you get an error regarding PGconn.quote_ident (Rails 2.3.x on Ubuntu 8.04) patch activerecord-2.3.4/lib/active_record/connection_adapters/postgresql_adapter.rb and add the following:

def PGconn.quote_ident(name)

immediately after the "class PGresult" definition at the top of the file. Once that's all done, the following:

$ rake RAILS_ENV=test db:create
$ rake RAILS_ENV=test db:schema:load
$ rake RAILS_ENV=test test

should work.

go have fun, write code, blow our minds

So that's how we roll. Awkward requirements will still crop up as we pick up new projects (or very old projects) so you'll always need a bit of apt/gem fu to get you through the day. Leave questions here or drop me a line at [email protected] or

Check out our other articles on Ruby on Rails development:

Ruby on Rails: Adding Factory Girl Steps to Turnip

Ruby on Rails: Using Rspec Macros and Metadata

Author image

About Adam Bachman

You've successfully subscribed to SmartLogic Blog
Great! Next, complete checkout for full access to SmartLogic Blog
Welcome back! You've successfully signed in.
Unable to sign you in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.