Invalid gem format, for every gem in rails

I've been trying to upgrade InstantRails2.0 to a more recent version of rails. I've updated gem to version 1.3.5. When I do a simple 'gem update rails', I got the 'Invalid gem format' error for activesupport-2.3.5.gem. After researching it and finding a couple threads here, I tried to delete this gem from the cache. Still didn't work, it just got re-loaded when installing rails. I tried going to version 2.3.3 of rails, since I don't need the latest and greatest, and a thread here suggested a problem in the latest repository.

I tried manually downloading the activesupport-2.3.3.gem and installing from that local downloaded gem. This appeared to work, so I downloaded rails-2.3.3.gem and tried to install this local copy. I continue to get the 'invalid gem format' for a different gem each time. Each time I manually download and 'gem install local' the version that last reported the error, and each time I get the 'invalid gem format' for another gem.

What's the root problem? I've just finally got rails 2.3.3 to install, but I need to do this on another machine as well, and am really not looking forward to doing this process again.

I'm having a similar problem, on osx updating rails

$ sudo gem update --system $ sudo gem update rails ERROR: Error installing rails:   invalid gem format for /opt/local/lib/ruby/gems/1.8/cache/ activerecord-2.3.5.gem

I've tried deleting the file, doing gem install vs update, etc and still get this error.

more info:

$ sudo rm /opt/local/lib/ruby/gems/1.8/cache/activerecord-2.3.5.gem $ sudo gem update rails --debug -V Exception `NameError' at /opt/local/lib/ruby/site_ruby/1.8/rubygems/ command_manager.rb:161 - uninitialized constant Gem::Commands::UpdateCommand Exception `Gem::LoadError' at /opt/local/lib/ruby/site_ruby/1.8/ rubygems.rb:827 - Could not find RubyGem test-unit (>= 0)

Updating installed gems GET 200 OK: RubyGems.org | your community gem host GET 200 OK: http://gems.github.com/latest_specs.4.8.gz Updating rails GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:135 - end of file reached Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:120 - end of file reached connection reset after 2 requests, retrying GET 200 OK: http://gems.github.com/specs.4.8.gz Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:135 - end of file reached Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:120 - end of file reached connection reset after 5 requests, retrying GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host Installing gem activerecord-2.3.5 Exception `Gem::package::FormatError' at /opt/local/lib/ruby/site_ruby/ 1.8/rubygems/package/tar_input.rb:110 - No metadata found! Exception `Gem::InstallError' at /opt/local/lib/ruby/site_ruby/1.8/ rubygems/installer.rb:121 - invalid gem format for /opt/local/lib/ruby/ gems/1.8/cache/activerecord-2.3.5.gem ERROR: Error installing rails:   invalid gem format for /opt/local/lib/ruby/gems/1.8/cache/ activerecord-2.3.5.gem Nothing to update

$ sudo rm /opt/local/lib/ruby/gems/1.8/cache/activerecord-2.3.5.gem $ sudo gem install activerecord ERROR: Error installing activerecord:   invalid gem format for /opt/local/lib/ruby/gems/1.8/cache/ activerecord-2.3.5.gem [22:09][jonathan@jsl:~/rails/jqui]$ sudo rm /opt/local/lib/ruby/gems/ 1.8/cache/activerecord-2.3.5.gem [22:09][jonathan@jsl:~/rails/jqui]$ sudo gem install activerecord ERROR: Error installing activerecord:   invalid gem format for /opt/local/lib/ruby/gems/1.8/cache/ activerecord-2.3.5.gem [22:11][jonathan@jsl:~/rails/jqui]$ sudo rm /opt/local/lib/ruby/gems/ 1.8/cache/activerecord-2.3.5.gem Password: [22:21][jonathan@jsl:~/rails/jqui]$ sudo gem install activerecord -- debug -V Exception `NameError' at /opt/local/lib/ruby/site_ruby/1.8/rubygems/ command_manager.rb:161 - uninitialized constant Gem::Commands::InstallCommand Exception `Gem::LoadError' at /opt/local/lib/ruby/site_ruby/1.8/ rubygems.rb:827 - Could not find RubyGem test-unit (>= 0)

GET 200 OK: RubyGems.org | your community gem host GET 200 OK: http://gems.github.com/latest_specs.4.8.gz GET 200 OK: RubyGems.org | your community gem host GET 200 OK: RubyGems.org | your community gem host Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:135 - end of file reached Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:120 - end of file reached connection reset after 2 requests, retrying GET 200 OK: http://gems.github.com/specs.4.8.gz Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:135 - end of file reached Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:120 - end of file reached connection reset after 4 requests, retrying GET 200 OK: RubyGems.org | your community gem host Installing gem activerecord-2.3.5 Downloading gem activerecord-2.3.5.gem GET 302 Found: RubyGems.org | your community gem host Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:135 - end of file reached GET 200 OK: http://s3.amazonaws.com/gemcutter_production/gems/activerecord-2.3.5.gem Exception `Gem::package::FormatError' at /opt/local/lib/ruby/site_ruby/ 1.8/rubygems/package/tar_input.rb:110 - No metadata found! Exception `Gem::InstallError' at /opt/local/lib/ruby/site_ruby/1.8/ rubygems/installer.rb:121 - invalid gem format for /opt/local/lib/ruby/ gems/1.8/cache/activerecord-2.3.5.gem ERROR: Error installing activerecord:   invalid gem format for /opt/local/lib/ruby/gems/1.8/cache/ activerecord-2.3.5.gem

I've been googling this for awhile. The most relevant post seems to be this:

I've updated gem to 1.3.5 and installed (from local) the rubygems- update-1.3.5.gem and then ran gem update --system. The update gem said it installed successfully and the gem update --system command returns with 'Nothing to update'. The above link mentioned that not connecting to the gemcutter and s3.amazon sites could be a problem. I've tested this, and I can't connect to them, I'm behind a firewall at work. Is this still a problem, even if the gem update --system command returns with 'Nothing to update'?

At this point, I'm tempted to blow everything away and start from scratch, if I knew that would resolve my gem errors somehow. I've recently got upgraded to rails 2.3.3, and now have run into this 'a copy of ApplicationController has been removed from the module tree'... error, and now because of this gem error it's difficult to change versions of rails, which I need to in order to keep working. Right now, I'm pretty unhappy with rails.