Sunday, October 17, 2010

Update Ruby Gems - CentOS

Circular dependencies suck. It's a really great thing that the entire package management system for Ruby is written with Ruby, until you need to update Ruby using said system when said system itself needs to be updated.

I'm currently trying to update Ruby and RubyGems on CentOS via yum and life has not been fun. Step 1, rubygems wasn't present, so I installed with yum. That went fine, except it installed version 0.9.2 of gems. Hmm, Ok, no big deal, I can run gem update --system. Nope, fail:

me@host$ sudo gem update ruby
Updating installed gems...
ERROR:  While executing gem ... (Gem::RemoteSourceException)
    HTTP Response 302

Great, rubygems changed their URL since 0.9.2 and apparently whatever http tool gems uses can't follow redirects. Well, after some debugging and total failure to find any help online, I discovered that gems maintains a sources file /usr/lib/ruby/gems/1.8/gems/sources-0.0.1/lib/sources.rb that lists the domain(s) of its repositories. Well, let me just change that to the new URL

module Gem
  @sources = [""]
  def self.sources

I ran the command again. STILL getting the 302. What the heck??? Alright, after some more debugging, I discover it's trying to download a yaml description file located at This loads fine in my browser, but a little telnet shows that I'm being redirected (obvious hint from the 302 earlier).

[me@host]$ telnet 80
Connected to (
Escape character is '^]'.
GET /yaml HTTP/1.1

HTTP/1.1 302 Found
Date: Mon, 18 Oct 2010 05:46:40 GMT
Server: Apache/2.2.3 (Red Hat) mod_ssl/2.2.3 OpenSSL/0.9.8e-fips-rhel5 Phusion_Passenger/2.2.15
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15
X-UA-Compatible: IE=Edge,chrome=1
X-Runtime: 0.000895
Content-Length: 0
Status: 302
Vary: Accept-Encoding
Content-Type: text/html

Hey, look! There's the redirect URL! A little update and I'm good to go.

module Gem
  @sources = [""]
  def self.sources

Then run,
[me@host]$sudo gem update --system
Updating RubyGems...
Attempting remote update of rubygems-update
Successfully installed rubygems-update-1.3.6
Installing ri documentation for rubygems-update-1.3.6...
Installing RDoc documentation for rubygems-update-1.3.6...
Could not find main page README
Could not find main page README
Could not find main page README
Could not find main page README
Updating version of RubyGems to 1.3.6
Installing RubyGems 1.3.6
ERROR:  Expected Ruby version >= 1.8.6, is 1.8.5
RubyGems system software updated

### Damn
### Maybe update ruby with gem? 

[me@host]$ sudo gem update ruby
Updating installed gems...
Attempting remote update of ruby
ERROR:  While executing gem ... (Gem::GemNotFoundException)
    Could not find ruby (> 0) in any repository

Nope, no go. So it looks like I am manually installing Ruby from the source since the yum repository only has Ruby as modern as version 1.8.5 dated 2006-08-25!! Isn't Ruby and Rails supposed to make life easier??