I was recently involved in updating a Rails 2.0.2 application to 2.1.1 and part of that task was to update the local Rails installation. So, I naturally tried
sudo gem update rails
which failed with the message
ERROR: could not find rails locally or in repository
That puzzled me a bit as a quick
gem list
confirmed that Rails 2.0.2 was indeed installed locally. Thinking that this was probably a RubyGem related issue, I decided to try and update that first:
sudo gem update --system
and was promptly greeted with
ERROR: While executing gem ... (NameError)
undefined local variable or method `remote_gemspecs' for #<Gem::Commands::UpdateCommand:0x101de10>
Ugly. A quick consultation with Uncle Google suggested that this was a problem with the current RubyGem installation and that I should be able to solve it by updating RubyGems manually from RubyForge. For some reason I can’t quite remember I made the mistake to go with version 1.2.0 instead of the latest and greatest 1.3.0 and ran into exactly the same problem once I had installed it:
sudo gem install rubygems-update-1.2.0.gem sudo update_rubygems sudo gem update --system ERROR: While executing gem ... (NameError) undefined local variable or method `remote_gemspecs' for #<Gem::Commands::UpdateCommand:0x101de10>
Ooops. Selecting 1.3.0 instead did the trick and allowed me to continue with the upgrade by first updating the Rails installation and then updating the project:
gem update rails rake rails:update
I then followed some of the suggestions made by Fabio Akita in Rolling with Rails 2.1.