Saturday
25Oct2008
Rails 2.1.2 and 2.2RC1: Update Your RubyGems
Saturday, October 25, 2008 at 2:20AM
There's a mismatch between the most recent Rails releases (2.1.2 and 2.2RC1) and older versions of RubyGems. Judging by what I've seen in various discussion fora, this is well on the way to being a FAQ. It's made more fun by the facts that
The error message doesn't implicate RubyGems
You may think you're up-to-date on RubyGems when you're not
If you're affected, you'll see this message when you try to run script/generate in a Rails application:
[sourcecode language='ruby']
undefined method empty?' for /_generator$/:Regexp
[/sourcecode]
If you see this, don't panic. It just means you need a newer RubyGems release. I'm not sure how current you need to be, but 1.1.1 is definitely too old. As I write this, 1.3.0 is current.
Now, in theory, to update to the latest version of RubyGems, you just need to run
[sourcecode language='ruby']
sudo gem update --system
[/sourcecode]
But - depending on what version of RubyGems you have installed, running that command may lie and tell you that you have nothing to update. If you're currently on RubyGems 1.1 or 1.2, you need to run a different set of commands to update RubyGems:
[sourcecode language='ruby']
sudo gem install rubygems-update
sudo update_rubygems
[/sourcecode]
You can check your current RubyGems version with
[sourcecode language='ruby']
gem -v
[/sourcecode]
If it reports 1.3.0 or later, you should be good to use the recent Rails releases.
If you're affected, you'll see this message when you try to run script/generate in a Rails application:
[sourcecode language='ruby']
undefined method empty?' for /_generator$/:Regexp
[/sourcecode]
If you see this, don't panic. It just means you need a newer RubyGems release. I'm not sure how current you need to be, but 1.1.1 is definitely too old. As I write this, 1.3.0 is current.
Now, in theory, to update to the latest version of RubyGems, you just need to run
[sourcecode language='ruby']
sudo gem update --system
[/sourcecode]
But - depending on what version of RubyGems you have installed, running that command may lie and tell you that you have nothing to update. If you're currently on RubyGems 1.1 or 1.2, you need to run a different set of commands to update RubyGems:
[sourcecode language='ruby']
sudo gem install rubygems-update
sudo update_rubygems
[/sourcecode]
You can check your current RubyGems version with
[sourcecode language='ruby']
gem -v
[/sourcecode]
If it reports 1.3.0 or later, you should be good to use the recent Rails releases.

Reader Comments (10)
Bless you, this post saved my bacon.
Works like a charm, thank you.
Thanks for your hint!
bah! all hassle in each upgrade...
This is the clearest explanation of how to handle this error on the net. Thanks for taking the time to do it!
Thanks for the tip, much appreciated!
Thank You, Mike! Helped me out (I had RubyGems 1.2).
Thank you! I couldn't find this info. on the RubyGems site!
I am current using Ubuntu 8.10. For me, if I ran the commands, rubygems would stay at 1.2 even though it looked like it "updated successfully"
If you are trying to update ruby gems on Ubuntu, you may need to install it manually. Sam Ruby has a good set of instructions. See http://intertwingly.net/blog/2008/11/23/RubyGems-1-3-1-on-Ubuntu-8-10
Hi, I thought i was getting close to success upon finding this thread.
After your alternative update commands, my terminal reports that i now have v1.3.3 but xcode debugger still tells me i have 1.0.1.
Due to installation issues with ruby/rails et al, on two different mac's I haven't been able to get past step one of a single tutorial.
Please can someone point me in the right direction!?!
Kindest regards
Jez