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).

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

I’m getting the same error & also trying to work this out. Any advice
welcomed

Also make sure what the file “~/.MacOSX/environment.plist” says or if
you set up the file correctly.

http://wiki.macromates.com/Troubleshooting/RubyVersionIssue

Hope this helps.

Thanks! Solved the problem completely! Here are the relevant steps:

  1. Create the ~/.MacOSX directory if it doesn’t already exist.
  2. Using the Property List Editor (in /Developer/Applications/
    Utilities), edit the ~/.MacOSX/environment.plist file (creating it if
    it doesn’t already exist).
  3. Create a child of the Root (create Root if it doesn’t exist) whose
    name is “PATH” (w/o the quotes), class is String, and value is the
    search path you want (the same as the one set up by .bashrc in my
    case).
  4. Log out then log in to apply the changes.
  5. To verify that the search path is correct, enter the following into
    a new TextMate window, select it, and execute it by typing ^R (control-
    r):

#!/bin/sh
echo “$PATH”

Ed

Greg,

Each of your issues run correctly for me, from both the menu and the
keyboard shortcut. One question: is the language in the menu at the
bottom of your spec file set to “RSpec”? That does affect which
keyboard shortcuts are active.

Ed

On Sep 6, 2:45 pm, “Greg H.” [email protected]

doh! thanks Ed, you got it in one :slight_smile: It was set to Ruby not
Rspec.

thanks Ed, I too can now see the nice colored output summary for rspec
in textmate, however…

What is weird is the following. Any ideas?

[A] - MENU BEHAVE DIFFERENTLY TO THE KEYBOARD SHORTCUTS: When I:
(a) Run the rspec commands via the TextMate menu using my mouse, e.g.
Bundle => RSpec => RunExamples, in this case I get the nice colored
output, but
(b) When I do Command-R (which is the shortcut for the same command as
listed in the menu), I don’t get this, but rather just a dialog box
with a text based output…

[B] - THE KEYBOARD SHORTCUT FOR “RUN SINGLE EXAMPLE” FAILS
I get this using the keyboard shortcut (again running this via the menu
works)

RubyMate r8136 running Ruby r1.8.6 (/opt/local/bin/ruby)

transaction_spec.rb
/Users/greg/source/myequity/vendor/plugins/rspec/lib/spec/runner/options.rb:218:in
files_to_load': File or directory not found: [, (RuntimeError) from /Users/greg/source/myequity/vendor/plugins/rspec/lib/spec/runner/options.rb:210:ineach’
from
/Users/greg/source/myequity/vendor/plugins/rspec/lib/spec/runner/options.rb:210:in
files_to_load' from /Users/greg/source/myequity/vendor/plugins/rspec/lib/spec/runner/options.rb:98:inrun_examples’
from
/Users/greg/source/myequity/vendor/plugins/rspec/lib/spec.rb:20:in run' from /Users/greg/source/myequity/vendor/plugins/rspec/lib/spec/runner.rb:192:inregister_at_exit_hook’
from /Users/greg/source/myequity/spec/models/transaction_spec.rb:3


[C] “Run commands from selected directories/files”
==> Not sure how to get this to work properly. If I click on a
directory in the directory tree, then use the menus to run this, it
doesn’t seem to narrow the report to just this directory. Anyone know
how you’re supposed to select a directory in text mate prior to
running this?

Thanks in advance is you can help