error loading rubygems from vendor_gem_source_index

I'm having trouble running script/generate due to the following error:

./script/../config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:1:in `require': No such file to load -- rubygems (LoadError)         from ./script/../config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:1         from ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:1:in `require'         from ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:1         from ./script/../config/../vendor/rails/railties/lib/initializer.rb:10:in `require'         from ./script/../config/../vendor/rails/railties/lib/initializer.rb:10         from ./script/../config/boot.rb:45:in `require'         from ./script/../config/boot.rb:45:in `load_initializer'         from ./script/../config/boot.rb:38:in `run'         from ./script/../config/boot.rb:11:in `boot!'         from ./script/../config/boot.rb:109         from script/generate:2:in `require'         from script/generate:2

its obviously tripping up on "require 'rubygems'" in vendor_gem_source_index.rb. I have no idea why this started happening (been working on this app with frozen rails for months) .. only that I recently upgraded my rails gem to 2.3.3. The version in the vendor folder is 2.2.

Any pointers would be really appreciated. Thanks in advance, Adam

Does this same error happen when you start up other Rails scripts (eg, script/console or script/server)?

The fact that it can't find rubygems seems to indicate something has gone seriously wrong with your Ruby install.

Here's some info that will help dignose (run at the command line, obviously):

which ruby which rails which gem gem --version

Also, are you manipulating the load path at all?

You may want to reply off-list, as this isn't really a Rails issue and I'll be able to reply faster.

--Matt Jones

I managed to solve the problem by uninstalling ruby with macports and reinstalling, following by rubygems via macports:

http://zeroeight.net/notes/archives/10-Setup-Ruby-and-Rails-on-Mac-OSX.html

(yes I am on osx, and yes I know its not a rails issue but thought I would post my solution anyhow)

Matt Jones wrote: