[EDIT, 2009-12-20]: For some time I steered away from installing Rails via APT on Ubuntu systems. I ran into a number of annoyances early on trying to get various bits of Ruby, Rails, libraries, and others installed and working together properly. And along the way I just never tested the following on a fresh Ubuntu system:
1 | sudo apt-get install rails sqlite3 |
That’s it. On a freshly baked Ubuntu 9.10 Desktop or Server, this will install (as of today):
- ruby: 1.8.7
- rails: 2.2.3
- irb: 0.9.5
- rake: 0.8.4
- rdoc: 1.0.1
- sqlite: 3.6.16
- rubygems: 1.3.5
And a host of dependencies of course. Perhaps I had simply FUBAR’ed my system by the time I tried this in the past, but it is working swimmingly now. Most of the other tutorials I’ve come across for Rails on Ubuntu take the more manual approach as well, but for now this looks like the way to go. For comparison, when I went through the more stepwise setup process using the script mentioned in the original content of this post below all the same versions were installed except for Rails itself, which was 2.3.5. So a slightly newer Rails version via gem than the Ubuntu repo, otherwise identical.
What follows is the original, more manual approach to getting everything installed. It might be useful to try if you run into problems with the repo package.
As I tried to get Ruby on Rails up and running on multiple (Jaunty Jackelope) Ubuntu 9.04 boxes, I came across a few… gotchas. While the steps described in this post will get Ruby, Rails and friends in place and working, there are a few places that have other potentially perilous options resulting in much gnashing of teeth.
What follows are the commands needed to get Rails working on a fresh Ubuntu 9.04 (server) box. To save some copying and pasting you can use this script which sets everything up and provides logging.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | sudo apt-get install ruby ruby-dev libopenssl-ruby rdoc irb build-essential cd /tmp # Check here to see if this is the latest: # http://rubyforge.org/frs/?group_id=126 wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz tar xzvf rubygems-1.3.5.tgz cd rubygems-1.3.5/ sudo ruby setup.rb # Without this 'gem' will either not work or will be something else: sudo ln -s /usr/bin/gem1.8 /usr/bin/gem # Test: gem --version # Should be: 1.3.5 sudo gem install rails # Test: rails --version # Should be: Rails 2.3.2 (or whatever is latest) # To get sqlite setup (default Rails DB backend): sudo apt-get install sqlite3 sudo apt-get libsqlite3-dev sudo gem install sqlite3-ruby |
Warnings:
- Don’t install gem with apt-get. This is not RubyGems. And don’t even install rubygems via apt-get. Install it from RubyForge.
- Don’t forget to make the symlink from gem1.8. This can cause no end of pain if you didn’t listen to the last warning.
- After RubyGems is in place, install Rails and other related items you need with it. Don’t use apt-get for these.
For more information on setup, covering DB and web server options on Ubuntu, check out the Community Guide.
[EDIT, 2009-10-04]: I just tried starting up Rails installed through the process above on a fresh Ubuntu 9.04 desktop. Turned out I also had to install libopenssl-ruby via apt-get. This is apparently due to some splitting of packages in the Ubuntu repo.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.









Thanks this was helpful. I was getting weird errors trying to install Mongrel until I did `sudo apt-get install ruby1.8-dev`. I also needed to apt-get install libopenssl-ruby as it is not included in the ruby install automatically in the Ubuntu world. To get a mysql client I used `apt-get install libmysql-ruby`.