Latest LQ Deal: Linux Power User Bundle
Go Back > Blogs > Murdock1979
User Name


Rating: 4 votes, 3.25 average.

A Day in the Life of Your Average Linux User: Rails on Ubuntu

Posted 11-18-2009 at 07:02 AM by Murdock1979

*Disclaimer: the following narration is for entertainment purposes only and does not necessarily reflect any real scenarios...or does it?

Let's follow a seemingly "simple" task for an average Linux user:

Scenario: Install Ruby on Rails on Ubuntu System

This sounds simple enough. Anyone familiar with Rails, knows there are 4 easy steps to installing a Rails web model:
1. Install Rubygems
2. Update Ruby Gem system
3. Install Rails
4. Run Rails application on specific directory
(we're going to leave Fastcgi/Apache stuff for another time)

Let's begin:

*Time: 12:00pm

Step I. Install Rubygems:

1. sudo su (makes the whole process easier)
2. apt-get install rubygems1.8

This installed without any hiccups. We are happy.

Step II. Update Gems

*Time: 12:02pm

2. sudo gem update --system

Odd, bash gives the following error:
ERROR: While executing gem ... (RuntimeError)
gem update --system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get.

Ok, so Debian/Ubuntu will be nice enough to update gems for me. So...

3. Update Apt-get


*Time: 12:05 pm

4. Wait a minute...Gems is still version 1.3.1. Ubuntu didn't update Rubygems? Ubuntu wouldn't be so dumb to make me upgrade my entire Operating System just to upgrade one little application, would it? It's obviously at its latest version. Let's move on and install Rails.

Step III. Install Rails

1. Run "gem install rails"

This takes a little time, do some df on another terminal to keep busy, but eventually everything goes well. Bash tells:
Successfully installed rails-2.3.4
along with telling me it installed the other dependencies and docs as well.

Step IV. Run Rails on Directory.

1. Excited that the process is almost finished. All we do now is run "rails /home/john/firstrails" and rails will magically install all those actionclasses files in the directory. Or will it?

Bash says it can't find the rails application. What gives?

*Time: 12:12pm

2. Let's try to find if Ubuntu installed the gems correctly, so I cd to /var/lib/gems/1.8/gems and everything is there. What could be wrong? Off to Google!

3. Google search for Ubuntu Rails Install. Aha...a page to install Rails on Ubuntu. Fantastic - this should help. It shows a how-to for ubuntu hardy, Janty-something, 8.04...oh, wait, it looks like I need to set my $PATH for Ubuntu to recognize the gem applications. That's funny, in Slackware, that wasn't necessary.

4. Here's goes: PATH=/var/lib/gems/1.8/bin:$PATH

*Time: 12:25pm

5. now we're ready to rumble. Let's leave root...exit.

6. Rails ~/firstrails

Still can't find rails? Oh, forgot to set the PATH for the user...set it for root by mistake, woopsy me.

7. PATH=/var/lib/gems/1.8/bin:$PATH

8. Let's try again: Rails ~/firstrails

Yay! Look at the standard output go!

create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales

*Time: 12:33pm

9. Looks like we're finished. Let's run the Webrick server just to see everything is in order: script/server

Not to worry, being around long enough gives someone the intuition that it won't work on the first go. And, lo and behold, Bash proudly heralds:
Rails requires RubyGems >= 1.3.2 (you have 1.3.1). Please `gem update --system` and try again.

Gee thank you Rubygems...if I need a higher version of Rubygems, why in the world would you, Rubygems yourself, install a version of Rails you can't even run!?

Oh, but didn't I install the latest version of RubyGems from the Ubuntu respository? Oh, silly me, I'm using an old, and I guess outdated, version of Ubuntu that came out barely a year ago. I guess Ubuntu wants me to upgrade my entire system just to install a little Rubygem application. Luckily, we're not dumb enough to listen. There's an easier way.

10. The solution: Install an earlier version of Rails that will run on Rubygems 1.3.1. Abra Cadabra: gem install rails --version 1.2.6!

Alright. We're gaining momentum now. Bash tells version 1.2.6 of Rails installed successfully. Everything looks good to go!

11. A rm -R on the ~/firstrails directory to start again clean.


12. Of course, when we run rails ~/firstrails, I would need to specify which version of rails, since we have the newest version and 1.2.6 installed. If Rubygems can install multiple versions, rails should have an option to determine which version to use. Surely doing a rails --help would give me the right information. Hmm, nope, the only option is --version, which shows the version, not sets it.

13. No choice, but to gem uninstall rails --version 2.4.3.

Ok, good, it's gone.

*Time 12:52pm

14. Let's run it again: rails ~/firstrails.

And the standard output goes wild!
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales

15. Crack our knuckles, we're ready to lauch: script/server


=> Booting WEBrick...
=> Rails application started on
=> Ctrl-C to shutdown server; call with --help for options
[2009-11-18 14:37:54] INFO WEBrick 1.3.1
[2009-11-18 14:37:54] INFO ruby 1.8.7 (2008-08-11) [i486-linux]
[2009-11-18 14:37:54] INFO WEBrick::HTTPServer#start: pid=16555 port=3000

*Time 1:00pm
Posted in Uncategorized
Views 2560 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 11:37 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration