Ruby on Rails: When script/generate crashes

So I’ve had in mind a project and decided to try it using Ruby on Rails. I already had a copy of this installed, so decided to sudo gem upgrade-all to catch-up, then rails myapp to build the stub application.

Usually after this point you hop in, and run script/generate with arguments to invoke new controllers and models. You know the stuff.

Except I was presented with this:
./script/../config/boot.rb:29: undefined method `gem' for main:Object (NoMethodError)
from script/generate:2

Not particularly helpful. Decided to uninstall the gems for rails including action*, active* and a couple of others too, installing rails afterwards and restoring those other packages as dependencies.

That, alas did not resolve the problem. Nor could the kind souls on irc://irc.freenode.net#rubyonrails who could only guess that ruby was messed up on the system. Not having a Mac for comparison, they could go no further.

So I checked and found a newer version of the ruby language. Installed it, no help.

So I checked and found a newer version of gem. Indeed ‘sudo gem update –system’ appears to self-update. I reinstalled rails afterwards. Lo and behold, script/generate sprang to life.

Oh happy days. I’m not too tired to proceed. Welcome to my world.

Advertisements