Failing in TextMate but not in rake

When I run a spec file from TextMate using the RSpec bundle’s “Run
Examples” command (either using command-R or the bundle menu item with
the spec file open), I get an error dialog with the following text:

“Missing the Rails 2.0.2 gem. Please gem install -v=2.0.2 rails,
update your RAILS_GEM_VERSION setting in config/environment.rb for the
Rails version you do have installed, or comment out RAILS_GEM_VERSION
to use the latest version installed.”

  • Running ‘rake spec SPEC=’ succeeds.
  • This line is in config./environment.rb: ‘RAILS_GEM_VERSION = ‘2.0.2’
    unless defined? RAILS_GEM_VERSION’
  • Running ‘gem list rails’ from the command line lists ‘rails (2.0.2)’
  • I’m running on OS X Leopard with a version of Ruby installed from
    source into /usr/local, per Dan Benjamin’s excellent instructions
    (Dan Benjamin). ‘which
    ruby’ finds ‘/usr/local/bin/ruby’, ‘which gem’ finds ‘/usr/local/bin/
    gem’.
  • In TextMate’s Advanced | Shell Variables, TM_RUBY is defined to ‘/
    usr/local/bin/ruby’ (w/o the quotes).
  • The thread in this group on the opposite problem (http://
    groups.google.com/group/rspec/browse_thread/thread/
    ab39c5aee198f797/15ba87d14324c14c?lnk=gst&q=textmate#15ba87d14324c14c)
    doesn’t apply to my problem, I think.

I’m guessing that TextMate is finding the wrong ruby or gem
environment somehow, but I can’t figure out how, or how to correct it.
Any suggestions would be appreciated!

Thanks in advance.

Ed