简体   繁体   English

如何更改 Textmate 使用的 Ruby 版本?

[英]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.我在 Snow Leopard 上使用 Textmate,并安装了 ruby 1.9。 The problem is that for some reason Textmate uses Ruby 1.8.2问题是由于某种原因 Textmate 使用 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.但是当我使用 IRB 或为 shell 运行 ruby 脚本时,使用了正确版本的 Ruby (1.9)。

How can I configure Textmate so it uses 1.9.2?如何配置 Textmate 以使其使用 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.我一直在谷歌搜索,显然你必须使用 T_RUBY 变量和 textmate,并在 OSX 中设置一些环境变量,但到目前为止,我发现的任何方法都不适用于我。

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:更新:我已经尝试在 textmate 中将 ruby 二进制路径添加到 TM_RUBY,但出现此错误:

> 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:如果您使用 RVM,也许您可以尝试键入:

> 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并将此路径设置为 shell 变量,如我的屏幕截图一样,在您的 textmate 偏好设置中命名为“TM_RUBY”

http://dl.dropbox.com/u/6931090/downloads/textmate-preferences.png 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 .在首选项/高级/shell 变量下,添加一个名为TM_RUBY的新变量。 And enter the absolute path of your ruby binary.并输入 ruby 二进制文件的绝对路径。

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 博客中所提到的,您需要做的就是告诉 text mate 您的路径变量。 TextMate does not load this information by default.默认情况下,TextMate 不加载此信息。 In Preferences, go to the Variables tab add a variable PATH (if it does not already exist) with the value, $PATH:/usr/local/bin .在首选项中,go 到变量选项卡添加一个变量PATH (如果它不存在),其值为$PATH:/usr/local/bin This tells TextMate to copy the system PATH.这告诉 TextMate 复制系统 PATH。 The system's ruby is in /usr/bin/ruby which is included in OSX default PATH.系统的 ruby 位于 OSX 默认路径中的/usr/bin/ruby中。 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).如果您安装了 ruby 的自定义版本,那么还安装了 append 该路径,例如这里我附加了/usr/local/bin (不要忘记冒号)。

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

If you use which ruby and TextMate says exec: rbenv: not found , you need to type this instead: rbenv which ruby .如果你使用which ruby和 TextMate 说exec: rbenv: not found ,你需要输入这个: rbenv which ruby Use that path in TM_RUBY .TM_RUBY中使用该路径。

Using the path that which ruby gave me didnt work.使用ruby给我的路径没有用。 After googling for a while, I found a solution that worked, using the auto-ruby path of rvm as the TM_RUBY variable.谷歌搜索了一段时间后,我找到了一个可行的解决方案,使用 rvm 的自动 ruby 路径作为 TM_RUBY 变量。 The path is: /Users/0al0/.rvm/bin/rvm-auto-ruby This only applies if you are using rvm, of course.路径是:/Users/0al0/.rvm/bin/rvm-auto-ruby 当然,这只适用于您使用 rvm 的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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