How to setup Textmate to use RVM

by Irish on June 28, 2010

Alright, so you’ve switched to using rvm but when you run cmd+r on a Ruby file in TextMate you’re still using your old system install of Ruby… Luckily it only takes a few easy steps to setup TextMate to use your rvm environment.

1) First make sure your install of TextMate if updated
Textmate -> Preferences -> Software Update -> Check Now

2) Next make sure all your bundles are up to date. The creator of rvm, Waynee Seguin, provides a small bash script to automate this process. You can check it out at this GitHub gist

3) Now get the rvm name of the Ruby version you want to use in TextMate. In my case I’m going to use my currently selected version “ruby-1.8.7-tv1_8_7_174″

$ rvm list
rvm rubies

   jruby-1.5.1 [ i386-java ]
   ruby-1.8.7-tv1_8_7_173 [ i386 ]
=> ruby-1.8.7-tv1_8_7_174 [ i386 ]
   ruby-1.9.1-tv1_9_1_378 [ i386 ]
   ruby-1.9.2-head [ i386 ]

4) Then run the rvm command to wrap this ruby version for TextMate

$ rvm wrapper ruby-1.8.7-tv1_8_7_174 textmate

5) Now set a TM_RUBY variable in your TextMate Preferences
Textmate -> Preferences -> Advanced -> Shell Variables

To the wrapper command generated by rvm for you, in my case it was found here:

/Users/cirish/.rvm/bin/textmate_ruby

6) Since TextMate will use it’s own builder, by removing it, we can use TM_RUBY as described above.

$ cd /Applications/TextMate.app/Contents/SharedSupport/Support/lib/
mv Builder.rb Builder.rb.backup

7) Last but not least, quit TextMate and re-open it to load these settings. You should now be all good :)

{ 9 comments… read them below or add one }

Manish May 10, 2011 at 4:01 am

Awesome!! Thanks a lot for sharing

Reply

Mario Zigliotto June 8, 2011 at 2:23 pm

note:

This might symptomatic of a newer version of TextMate as this post is a bit stale but for me, step 6 was not necessary.

I simply built the rvm wrapper, added the TM_RUBY variable and restarted textmate.

On apple+r i see ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] so it appears all is good! :)

thanks for the post.

Reply

Kyle Sexton June 15, 2011 at 3:29 pm

Thanks for the tip, works great!

Reply

tek_yogi July 16, 2011 at 4:35 pm

I think this issue might be updated on the rvm site.

http://beginrescueend.com/integration/textmate/

I just set up the rvm-auto-ruby approach, and now my run command looks at the project .rvmrc file and executes that version of ruby, if no .rvmrc it defaults to the rvm default. Beautiful.

Reply

Irish July 16, 2011 at 4:43 pm

You’re correct, this post is pretty old. I need to update it to use the rvm-auto-ruby approach.

Reply

dpree November 3, 2011 at 4:44 am

a bit offtopic, but before i wrote this http://uberfork.com/post/12280974742/integrate-rbenv-with-textmate i also looked here to find some answers how to setup textmate to use rbenv ;)

Reply

nuc January 17, 2012 at 9:38 am

Works as a charm :)

Thank you!

Reply

lucas January 26, 2012 at 5:53 pm

Sweet. Worked like a charm

Reply

Michael May 30, 2013 at 2:52 pm

Thanks for showing this technique. I automated the “rvm wrapper” step with after_use_textmate hook, which should soon be shipped with rvm.

gist: https://gist.github.com/mwlang/5681232
rvm pull request: https://github.com/wayneeseguin/rvm/pull/1931

Reply

Cancel reply

Leave a Comment

{ 1 trackback }

Previous post:

Next post: