Using the Rails bundle in TextMate

I've been exploring the Rails bundle in TextMate. It is really useful but I had a few issues getting it up and running so if it helps anyone else I'm documenting them here.

My environment

I’m running Snow Leopard and installed Ruby, RubyGems and Rails by following the excellent Hivelogic article.

I had mostly been using the command line for things like running tests but the bundle has that baked in allowing you to run the test you have open with a simple COMMAND + R shortcut.


The first issue I came up against was that TextMate wasn’t finding the right version of Rails.

    Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 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.

I assumed this was a path issue so added /usr/local/bin to /etc/profile but no luck. The solution is to add this to TextMate’s Shell Variables. Go to Preferences > Advanced > Shell Variables. Then add a row with the variable “PATH” and the value “/usr/local/bin” (or wherever you want TextMate to look).

This allows individual tests to be run but when running all tests via the bundle I got

    rake aborted! stack level too deep /Users/george/Sites/istink/Rakefile:10 (See full trace by running task with --trace) (in /Users/george/Sites/istink)


There is a ticket on the Macromates site about this. The solution is to add this line to the top of your Rakefile

$:.reject! { |e| e.include? 'TextMate' }

This gets over that problem but I then ran into a conflict with TextMate’s Builder file which was throwing another error

    /Applications/ `blank_slate_method_added': stack level too deep (SystemStackError) 	from
    ... snip ...

I found a helpful comment on Dr Nic’s site that fixes the problem. So I did

    cd /Applications/
    mv Builder.rb Builder.rb.old

It works! Now I can run any tests I want from within TextMate with the shortcut ^/. Productivity up!


Can you help make this article better? You can edit it here and send me a pull request.

See Also