I had exactly the same error as this...
While installing Rails 3 my computer suffered a power outage. After restarting the computer and continuing the Rails 3 installation the process failed with this exact same error. The problem was due to the gem install cache which had corrupted / empty gem files. My solution was to clear this cache and run the install again, as follows:
- Find out the location of your cache using
gem env
- List all the gems in that cache, e.g.
ls -l /usr/lib/ruby/gems/1.8/cache/
- Compare with successfully installed gems using
gem list
- Remove the gems from the cache list that are missing from the gem list e.g. using
rm
- I also had to remove some empty / corrupt gemspec files from the specification directory
ls -l /usr/lib/ruby/gems/1.8/specifications/
- Continue the installation, e.g.
sudo gem install -v=3.0.6 rails --no-rdoc --no-ri
Hope this helps someone else who has a power outage or other external failure during a gem install process!