Topic: HOWTO: Install Ruby on Rails on Ubuntu Linux

This tutorial will show you how to install Ruby on Rails on a base install of Ubuntu Linux. This tutorial should also work for any similar Linux distributions, such as Kubuntu, Xubuntu, or any Debian-based distribution.

We'll start with a base install ("server" install in Ubuntu), but you can do a graphical install as well if you don't want a command line only when you log in smile.

So let's get started!

NOTE: anything marked in these:

code blocks

Are to be run in a terminal/command prompt window, unless otherwise noted.


1. Log in and open a terminal if you need to. First we'll install Ruby 1.8 and Ruby's development libraries. We'll also install IRB, which is quite useful while trying Ruby programming.

sudo apt-get install ruby ruby1.8-dev irb

You will be prompted for your password so be sure to get it right!

2. Now that Ruby's installed, let's install SQLite 3. SQLite is a lightweight, file-based database that's good for development. Feel free to use another database here if you'd like, such as MySQL or PostgreSQL.

sudo apt-get install sqlite3

3. Now let's start installing Rails. First you'll need RubyGems. Download it this way:
wget http://rubyforge.org/frs/download.php/5 … 0.8.11.tgz

4. Now unpack the RubyGems package:
tar -zxvf rubygems-0.8.11.tgz

5. Now go into the directory created from unpacking, and run the setup program:
cd rubygems-0.8.11
sudo ruby setup.rb

6. Now we have RubyGems installed, so we can install Rails and friends.

sudo gem install rails --include-dependencies

This will install the latest version of Rails (1.1.4 as of this writing).

7.OPTIONAL: Install Mongrel, the fast server for Rails:

sudo apt-get install build-essential
sudo gem install mongrel --include-dependencies

8. Create a test Rails app somewhere
rails my_test_app

9.Run your newly created Rails app to see if everything is working:

If you installed Mongrel, do this:

cd my_test_app
mongrel_rails start -d

If you didn't install Mongrel, do this:
cd my_test_app
ruby script/server

10. Go to http://localhost:3000 in your browser. Congratulations, you're on Rails!

NOTE FOR MONGREL USERS: Edge Rails (the version of Ruby on Rails that is under active development) now has support for running Mongrel through script/server if you have it installed. All you will have to run then is

ruby script/server

The script will start Mongrel instead of WEBrick if found.

Good luck with your install, and post any questions you may have here.

vinnie - rails forum admin

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Step 6 is a horrible idea.  The correct thing to do is to install the "ruby" package via apt-get.  This ensures that /usr/bin/ruby points to the current Ruby installation in the future, without manually interfering with system directories.

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Very helpful article, thanks.

Two things; I followed this to install on Ubuntu 6.06 LTS! desktop. I used the Synaptic Package Manager for Ruby and Step 6 is required, as it installed as ruby1.8. Also mongrel appeared to install, but would not run. Fixed by using Synaptic Package Manager to install "build-essential", then gem uninstall mongrel and then re-install. To see any errors in mongrel leave off the -d option in step 10.

Last edited by mconiegs (2006-08-31 08:12:46)

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Yeah! You should definitely use apt-get to install ruby.
You also have to install the "build-essintial" package to successfuly install Mongrel. You need it because parts of Mongrel are in C/C++ and have to be compiled when installing.
If you don't have build-essential installed, Mongrell will install, but it will fail to start with an error like this:

** Starting Mongrel listening at 0.0.0.0:3000
/usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/
mongrel.rb:666:in `register': undefined method `resolve' for
nil:Mongrel::URIClassifier (NoMethodError)

My homepage: http://www.komendera.com/
Working at: http://www.abloom.at/
My blog: soaked and soaped http://soakedandsoaped.com/

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Good points everyone. I edited my original post.

vinnie - rails forum admin

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

I uninstall ruby and sqlite3 and went through the post again and all worked fine except that using apt-get with ruby, (step 1), gave me a strange result in that there was no ruby executable in /usr/bin, although the sym-link was there.
I did a synaptic re-installation and it all worked fine. I assume it was me, but just thought I would share incase anyone else had an issue.

Again thanks for easy and helpful article.

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

After I installed rails as instructed above, I got the following error:

Routing Error

Recognition failed for "/rails/info/properties"

Any help would be appreciated.

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Dieter Komendera wrote:

Yeah! You should definitely use apt-get to install ruby.
You also have to install the "build-essintial" package to successfuly install Mongrel. You need it because parts of Mongrel are in C/C++ and have to be compiled when installing.
If you don't have build-essential installed, Mongrell will install, but it will fail to start with an error like this:

** Starting Mongrel listening at 0.0.0.0:3000
/usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/
mongrel.rb:666:in `register': undefined method `resolve' for
nil:Mongrel::URIClassifier (NoMethodError)

I'd love to rely on the apt-get packages but the versions lag behind by a significant delay.  The last I checked the ruby package was still at 1.8.4, and for the longest while it was at 1.8.3, which was completely unusable for a rails deploy.

So while I agree using the package system is usually the best bet, there are times that it just doesn't get the job done.

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Hi all
I am getting problem in configuring eclipse for ruby on rails. I am refering a tutorial at the following link
file:///C:/Documents%20and%20Settings/Jain/Desktop/Sonjaya%20Tandon%20%BB%20HOW-TO%20%20Configure%20eclipse%20for%20Ruby%20on%20Rails.htm

I am getting problem in step 19. After configuring RDT plug-in and Rad Rails plug-in, rails Installs does not appear. So when I try to create a new rails project,following error appear:
rails is not recognized as an internal or external command.
and the necessary files are not generated.
I dont know what to do. Please help me out.

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

You should definitely NOT use apt-get to install ruby if you are running 64-bit Ubuntu.  I set up my new Opteron system a few weeks back to be a rails dev machine.  If anybody runs into problems, drop me a line.

BrewControl.com - Brewery and Brewpub management powered by RoR

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

I'm getting an error after step 6:

root@root-desktop:~$ sudo gem update --system
/usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)

root@root-desktop:~$ sudo gem install mongrel
/usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

cray,

Please post what gem -v gives out.

As for the tutorial, I don't understand why everything is not installed at once, like so:

sudo apt-get install ruby ruby1.8-dev irb sqlite3 rubygems build-essential

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Radar,
gem -v gives me the same error:
/usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)

does the installations method u suggested , install ruby on an apache or mongrel server?
thks!

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Cray,

This is a fairly common issue when you upgarde rubygems to 1.0+, you need to add the line

require 'rubygems/gem_runner'

to the /usr/bin/gem file

On another note:

The original post is a bit outdated, I'd skip steps 3 - 6 and instead install the apt-get package for rubygems and then issue an upgrade if I want to ensure I'm on latest so something like:

sudo apt-get install ruby ruby1.8-dev irb rubygems build-essential

followed by

sudo gem install rails mongrel

should be enough to get you going

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Thanks sambo.Gems aint fussing now.
But It now gives me a new error.
"aeshan@aeshan-desktop:~$ sudo gem install rails --include-dependencies
sudo: must be setuid root
"

whats setuid?
Thanks

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

http://ubuntuforums.org/showpost.php?p= … ostcount=4

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Thanks for the nice HowTo. Just installed it on Pardus Linux.

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

Here is a step by step procedure for installing Ruby on rails

http://iweavers.blogspot.com/2008/07/ho … buntu.html

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

During installing mongrel in step 7,

We also need to install @ ruby1.8-dev@ package. When you try to install Mongrel without this installed, it will complain with this errormessage:

extconf.rb:1:in `require

Re: HOWTO: Install Ruby on Rails on Ubuntu Linux

@ Nimesh_Nikum

Thanks for the advice. I had the exact same problem.