Updating Rails on Leopard – Gem::RemoteFetcher::FetchError

Just picked up a great book on Rails coming from a PHP background called Rails for PHP Developers. The examples in the book call for Rails version 2.0.2. I ran rails -v and lo-and-behold, the version of rails that is packaged with Leopard is pretty old.

Rails uses a program called RubyGems for installation (as well as the installation of numerous other Ruby-related plugins and app). First I needed to verify that I had a current version of Ruby gems:

gem -v
# 1.0.1

According to RubyForge, the latest version of RubyGems is 1.1.1, so I ran this script to update. Gems is pretty cool because you can keep your software updated from the terminal (usually) without having to download anything manually:

gem update --system
# Updating RubyGems...
# Attempting remote update of rubygems-update
# Successfully installed rubygems-update-1.1.1
# 1 gem installed
# Updating version of RubyGems to 1.1.1
# Installing RubyGems 1.1.1
# ...
# RubyGems system software updated

gem -v
# 1.1.1

Now that Gems is current, I can update Rails. Running gem update rails didn't seem to work very well so I think it's best to remove previous versions of Rails (and the book I mentioned above said as much) and do a clean install:

gem uninstall rails

I removed all versions and executables as well. Once this is done, you can install Rails fresh (currently version 2.0.2). Trouble is, when I ran gem install rails I got the following error:

gem install rails
# ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
# timed out fetching http://gems.rubyforge.org/gems/activerecord-2.0.2.gem

Through a bit of googling/trial and error and running gem help install I found an option to (-p, --[no-]http-proxy [URL]) use an "HTTP proxy for remote operations" and this seemed to do the trick:

gem install rails -p -V
# Installing gem actionpack-2.0.2
# Downloading gem actionpack-2.0.2.gem
# ...
# 4 gems installed
# ...

rails -v
# Rails 2.0.2

Yay, Rails! All the -V flag does is (I think) to show the verbose details of the installation (so it prints out the files it's writing and whatnot). I'm no *nix whiz so feel free to correct me. Hope the proxy idea helps someone else out.

January 27th, 2008 | Permalink