Tuesday, December 7, 2010

Fixing Ruby Gems On Mac OS Snow Leopard

Today I tried to install the ruby client library for cassandra. The gem install command failed with the following error message:

helmut$ sudo gem install cassandra
ERROR:  could not find gem cassandra locally or in a repository 

Running the same command with the verbose flag produced the following output:

helmut$ sudo gem install cassandra -V
HEAD 302 Found: http://gems.rubyforge.org/latest_specs.4.8
Error fetching remote data:  bad response Found 302 (http://gems.rubyforge.org/latest_specs.4.8)
Falling back to local-only install
ERROR:  could not find gem cassandra locally or in a repository


This output shows that the gem command tries to download the file http://gems.rubyforge.org/latest_specs.4.8 but cannot find it. In the next step it tried to download this file with curl. This worked. Downloading the file with the verbose flag produced the following output:

helmut$ curl -v http://rubygems.org/latest_specs.4.8
* About to connect() to rubygems.org port 80 (#0)
*   Trying 72.4.120.124... connected
* Connected to rubygems.org (72.4.120.124) port 80 (#0)
> GET /latest_specs.4.8 HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: rubygems.org
> Accept: */*
> 
< HTTP/1.1 302 Found
< Date: Tue, 07 Dec 2010 08:18:46 GMT
< Server: Apache/2.2.3 (Red Hat) mod_ssl/2.2.3 OpenSSL/0.9.8e-fips-rhel5 Phusion_Passenger/3.0.0
< X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.0
< X-UA-Compatible: IE=Edge,chrome=1
< X-Runtime: 0.001094
< Location: http://production.s3.rubygems.org/latest_specs.4.8
< Content-Length: 0
< Status: 302
< Vary: Accept-Encoding
< Content-Type: text/html
< 
* Connection #0 to host rubygems.org left intact
* Closing connection #0
This output shows, that the request was redirected to http://production.s3.rubygems.org/latest_specs.4.8. Obviously the location of the ruby gems repository has changed. To fix the above problem, add the new repository url and remove the old one:
helmut$ sudo gem sources -a http://production.s3.rubygems.org/
helmut$ sudo gem sources -r http://gems.rubyforge.org/
After this fix the installation works without errors:
helmut$ sudo gem install cassandra
Successfully installed cassandra-0.8.2
1 gem installed
Installing ri documentation for cassandra-0.8.2...
Installing RDoc documentation for cassandra-0.8.2...

No comments:

Post a Comment