Rails: If rake db:create:all yields undefined method `collect' then update gem itself.

Today the team was attempting to create a new Facebooker app in Rails 2.0 (actually 2.1.0) and we were running into the following problem (running on Mac OS X 10.5 Leopard, where the prompt is “dir user$”):

dir user$ rake db:create:all
undefined method `collect' for #<Gem::Version::Requirement:0x148c7a8>

It took us a while, but we eventually figured out:

  • Locking the Rails version wasn’t the problem (apparently),
  • Updating the json, haml, and facebooker gems didn’t seem to help,
  • Removing and reinstalling the Rails gem didn’t help, but
  • updating gem itself from version 0.8 to version 1.2.0 did help. The way to do that is simply:

    dir user$ sudo gem update --system
    

    To verify this worked, try the following:

    dir user$ gem -v
    1.2.0
    

At this point we were able to then run rake db:create:all successfully.


August 6th, 2008
Alan Hogan (@alanhogan).  Contact · About