Installing Ruby on Rails on Ubuntu 8.04 - Adventures in Switching to Linux

Sunday, September 21, 2008

Installing Ruby on Rails on Ubuntu 8.04

I've been exploring web app frameworks lately in hopes of starting work on a new site. I first looked at some PHP implementations, namely CodeIgniter and CakePHP. I mostly looked at those thanks to all the cheap and easy hosting available for PHP. I also thought some about a Java framework like Spring or Struts but I mostly write Java these days so I wanted to branch out. What I finally decided on was Ruby on Rails. I have dabbled with Rails a little in the past and have started working on a few real projects recently that are also using Rails so I will be learning it anyway.

So far all my development in Rails has been on Windows. Rails is rather Mac centric and I am a little unsure of the Linux support. I know that the one other project I am working on is deployed on Ubuntu 8.04 server so surely I can develop on it too.

First thing is first. Install ruby:

$ sudo apt-get install ruby
And then ruby doc:
$ sudo apt-get install rdoc
(If you don't install ruby doc, you are going to get an error later when installing ruby gems.)

Now you could at this point install rails and ruby gems using apt-get or synaptic but you don't want to. Rails is currently at version 2.1.1 and ruby gems is version 1.2.0 but the Ubuntu repositories only have versions 2.0.2 and 1.1.1 respectively. If Ubuntu backports had newer versions we would be set but I don't see rails in the mix. Having a package manager built into the OS is not something that Windows and Mac have available to them natively so ruby has gems as a package manager. Unfortunately this can conflict with the OS package manager so that is why we aren't going to install ruby gems or rails with apt-get.

So now you want to download ruby gems here. Extract it (anywhere), fire up a terminal, change to the directory you just extracted and run:
$ sudo ruby setup.rb
If you happen to get the error message: ./lib/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- rdoc/rdoc (LoadError) then you skipped over my point to install ruby doc above. Go back and install that and you will be caught up again.

After a minute or so you will have ruby gems installed. To install rails run:
$ sudo /usr/bin/gem1.8 install rails
After a few minutes more, you are ready to start developing with rails. You may also want to consider using Eclipse and Aptana.


Also, if after this when trying to fire up WEBrick you get the error: /usr/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:229:in `require_frameworks': no such file to load -- openssl (RuntimeError) You will need to install libopenssl-ruby:
$ sudo apt-get install libopenssl-ruby
You may need to install mysql too even if you are only accessing a remote database so keep that in mind too.

7 comments:

Mike said...

Have you checked out Python and Django?

stephenlane80 said...

Hi,
I think ruby on rails is a bit of a dead stick, you would be better off sticking to java or dot net with something like dotnetnuke, there is a bugger community and you will receive more support, my 2 cents ....

Software Development Limerick | Software Outsourcing Ireland

Kirk v. Quesnelle said...

Hey, Thanks for the great post!

I like how you covered the errors that you may run into


@ Stephen, dude.. how can you be so ignorant? Give me a break, seriously...lol

mdgrech said...

is aptana your ide of choice? I've just been using gedit with a bunch of plugins. Its very light weight but ive been considering switching to a full blown ide

Aruna said...

I used apt-get for installation and faced many issues. I found it a lot more easier with rvm.
Refer http://technologyandleadership.com/rvm-%E2%80%93-easy-installation-of-ruby-on-rails-on-ubuntu/

Admiral Adney said...

@ Stephen:

dont be so rude buddy ruby on rails development is not a dead stick.i think first you have to go for it :D then you can fell the difference

Tejuteju said...

Really nice blog post. provided a helpful information. I hope that you will post more updates like this Ruby on Rails Online Course Bangalore