简体   繁体   中英

How do I change the Ruby version Textmate uses?

EDIT: I found a solution for this, you can read it in my answer bellow.

I am using Textmate on Snow Leopard, and have installed ruby 1.9. The problem is that for some reason Textmate uses Ruby 1.8.2

But when I use IRB, or run ruby scripts for the shell, the proper version of Ruby (1.9) is used.

How can I configure Textmate so it uses 1.9.2?

I've been googling and apparently you have to use the T_RUBY variable and textmate, and set some environment variable in OSX, but so far none of the methods I've found works for me.

Could someone give a step by step solution to this problem?

Update: I already tried adding the ruby binary path to TM_RUBY in textmate, and I get this error:

> Can't find
> “/Users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
> /Users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
> /Users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
> ” on PATH. Theme: The current PATH is:
> /usr/bin /bin /usr/sbin /sbin Please
> add the directory containing
> “/Users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
> /Users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
> /Users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
> ” to PATH in TextMate's Shell
> Variables preferences.

If you use RVM, maybe you can try to type:

> which rvm-auto-ruby
/Users/eddie/.rvm/bin/rvm-auto-ruby

and set this path as a shell variable named "TM_RUBY" in your textmate perferences like my screenshot

http://dl.dropbox.com/u/6931090/downloads/textmate-preferences.png

Hope that helps:)

Under preferences / advanced / shell variables, add a new variable called TM_RUBY . And enter the absolute path of your ruby binary.

You can get the latter by opening a terminal and typing:

which ruby

The solution is actually very easy, no special install procedures are needed. As mentioned on the TextMate blog all you need to do is tell text mate your path variable. TextMate does not load this information by default. In Preferences, go to the Variables tab add a variable PATH (if it does not already exist) with the value, $PATH:/usr/local/bin . This tells TextMate to copy the system PATH. The system's ruby is in /usr/bin/ruby which is included in OSX default PATH. If you install a custom version of ruby then also append that path, for example here I have appended /usr/local/bin (don't forget the colon).

在 TextMate2 首选项窗格中更新 PATH 变量

If you use which ruby and TextMate says exec: rbenv: not found , you need to type this instead: rbenv which ruby . Use that path in TM_RUBY .

Using the path that which ruby gave me didnt work. After googling for a while, I found a solution that worked, using the auto-ruby path of rvm as the TM_RUBY variable. The path is: /Users/0al0/.rvm/bin/rvm-auto-ruby This only applies if you are using rvm, of course.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM