Getting Ruby setup on Ubuntu – Jaunty
UPDATED: Added RSpec for Rails as well
Here are some quick steps to get you up and running with Ruby on Ubuntu, Take about 15 minutes depending on your internet connection.
Step 1: The first thing you need to do is update the packages in Ubuntu open the terminal window (Applications Menu | Accessories | Terminal) and type in the following commands.
sudo aptitude update
sudo aptitude dist-upgrade
Step 2: The next package will insure you have everything you need in order to build ruby packages on your system.
sudo aptitude install build-essential
Step 3: Type in the following command to install Ruby NOTE: this is all ONE command
sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby
Step 4: Type in the following command to install SQLite3 NOTE: ONE command
sudo aptitude install sqlite3 libsqlite3-ruby1.8
Step 5: Install Ruby Gems NOTE: Multiple commands
wget http://rubyforge.org/frs/download.php/55066/rubygems-1.3.2.tgz
tar xvzf rubygems-1.3.2.tgz
cd rubygems-1.3.2
sudo ruby setup.rb
!! You should get an error stating that Ruby command not found !!
Step 6: creating the ruby symlink (symlink stands for symbolic link, windows user can think of it like a shortcut)
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
Step 7: Install ruby gems NOTE: you should be in the directory rubygems-1.3.2 when you run this command
sudo ruby setup.rb
Step 8: We need to create the remaining symlinks for ruby utilities NOTE: Multiple commands
sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
Installing Rails
Step 9: Install Rails
sudo gem install rails –no-rdoc –no-ri
Step 10: Create a test project NOTE: Multiple commands
cd ~
mkdir apps
cd apps
mkdir rails_apps
cd rails_apps
rails testapp
Step 9: Start Webrick web server in your testapp directory
./script/server
Step 11: Open up Firefox and navigate to http://localhost:3000, you should see a page with the text:
Welcome aboard
You’re riding Ruby on Rails!
Step 12: Install Rspec
gem install rspec
Installing source control
Step 13: Install subversion
sudo aptitude install subversion
Step 14: Install Git because you are going to use plugins from GitHub
sudo aptitude install git-core
Step 15: Install Git-svn
sudo aptitude install git-svn
Step 16: Add SVN Like Shortcuts to Git
git config –global alias.st status
git config –global alias.ci commit
git config –global alias.co checkout
git config –global alias.br branch
Step 17: configure the global user for Git
git config –global user.name “Put your full name here”
git config –global user.email you@rackspace.com
Step 18: colorize the output for Git
git config –global color.branch auto
git config –global color.diff auto
git config –global color.interactive auto
git config –global color.status auto
Installing RSpec for Rails
I want to put a disclaimer here that this is my preferred way of installing RSpec from GitHub. It is not the only way.
Step 19: Navigate to the root of your Rails project. I am assuming that in this case it will be “testapp”
Step 20: Install Rspec for Rails from GitHub as Git submodules. NOTE: Multiple commands
git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec
git submodule add git://github.com/dchelimsky/rspec-rails.git vendor/plugins/rspec-rails
Step 21: Run the rspec generators, this will enable the rspec_* controller, scaffold, model generators
ruby script/generate rspec
This is going to drive you nuts if you have to remember to do this for every rails project you create so I created a simple bash script. Actually the contains more than the bash script it also has the aliases that I use for Rails development.
Step 22: Navigate to your home diretory
cd ~
Step 23: Create the .rails_aliases file
gedit .rails_aliases
Step 24: In gedit copy the following text to the .rails_aliases file
alias ror-doc-spec=’open -a Firefox doc/plugins/rspec-rails/index.html’
alias ror-doc=’open -a Firefox’
alias ror-scaffold=’ruby script/generate rspec_scaffold’
alias ror-controller=’ruby script/generate rspec_controller’
alias ror-model=’ruby script/generate rspec_model’
alias ror-git-customerror=’script/plugin install git://github.com/gumayunov/custom-err-msg.git’
alias ror-console=’ruby script/console’
alias rapps=’cd ~/apps/rails_apps’
alias ror-serv=’ruby script/server’
alias ror-logtail=’tail -f log/development.log’
# Configures a rails app to use rspec
specrails(){
git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec
git submodule add git://github.com/dchelimsky/rspec-rails.git vendor/plugins/rspec-rails
ruby script/generate rspec
}
Step 25: Save the file and close gedit
Step 26: Open your .bashrc file from the terminal window
gedit .bashrc
Step 27: Add the reference to your .rails_aliases file in your .bashrc at the top of the file add the following line:
source ~/.rails_aliases
Step 28: Save the file and exit gedit
Now if you want to add RSpec to any rails project you simply navigate to the root of a rails project and type:
specrails
If you want to add a controller with RSpec specs you simply have to type:
ror-controller BlogPost title:string author:string content:text …
Hope this helps! Happy coding!
Post Footer automatically generated by Add Post Footer Plugin for wordpress.

There is a new editor for ubuntu/linux that accepts textmate bundles. its called redcar editor:
http://redcareditor.com/
I personally use gedit with the gmate mod to make it more like textmate
I would recommend grabbing the rspec-rails gem as well. It has some specialised test helpers for testing controllers and so on.
@schambers
Redcar has tremendous potential for Textmate users switching to Linux but it is still to Alpha for me. But definitely on the radar.
@Garry I was going to add that but ….oh hell never mind I will just update it.
Excellent post, this will help me greatly!
There’s a metapackage called “ruby-full” … just do
sudo apt-get install ruby-full
Cool. What the heck is “Ruby and Rails”. You don’t even give the rest of us a clue as to what it is! I still don’t know what it is after reading the article and the posts.
Thanks for the heads up on redcar.
Its very annoying how you have broken up the aptitude install steps instead of combining them into one
@Theodore – The title says Setting up Ubuntu Jaunty for Ruby and Rails development. If you don’t know what ubuntu, jaunty or ruby on rails is then GOOGLE it! The article did what it set out to do!
Good article and thanks!
Installing rspec fails
$ git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec
fatal: Not a git repository
Thank you thank you thank you.
Portable Ubuntu needs this bad! Although for some reason, rake has to be installed separately, but at least I can update gems now, and *finally* get to work…
Regarding fail message:
Installing rspec fails
$ git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/rspec
fatal: Not a git repository
solution: run this command while inside the testapp directory
git init