编辑:我找到了一个解决方案,您可以在下面的我的回答中阅读它。
我在 Snow Leopard 上使用 Textmate,并安装了 ruby 1.9。问题是由于某种原因 Textmate 使用 Ruby 1.8.2
但是当我使用 IRB 或为 shell 运行 ruby 脚本时,会使用正确的 Ruby 版本(1.9)。
如何配置 Textmate 以使其使用 1.9.2?
我一直在谷歌搜索,显然你必须使用 T_RUBY 变量和 textmate,并在 OSX 中设置一些环境变量,但到目前为止,我发现的方法都不适合我。
有人可以一步步解决这个问题吗?
更新:我已经尝试将 ruby 二进制路径添加到 textmate 中的 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.
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.
发布评论
评论(5)
如果您使用 RVM,也许您可以尝试输入:
并在您的文本伙伴首选项中将此路径设置为名为“TM_RUBY”的 shell 变量,如我的屏幕截图
http://dl.dropbox.com/u/6931090/downloads/textmate-preferences.png
希望有帮助:)
If you use RVM, maybe you can try to type:
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 :)
在首选项/高级/shell 变量下,添加一个名为
TM_RUBY
的新变量。并输入 ruby 二进制文件的绝对路径。您可以通过打开终端并输入以下内容来获取后者:
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
并且 TextMate 显示exec: rbenv: not find
,您需要输入:rbenv which ruby
。在TM_RUBY
中使用该路径。If you use
which ruby
and TextMate saysexec: rbenv: not found
, you need to type this instead:rbenv which ruby
. Use that path inTM_RUBY
.解决方案实际上非常简单,不需要特殊的安装过程。正如 TextMate 博客 中提到的,您所需要做的就是告诉 Text mate你的路径变量。 TextMate 默认情况下不加载此信息。在“首选项”中,转到“变量”选项卡,添加变量
PATH
(如果尚不存在),其值为$PATH:/usr/local/bin
。这告诉 TextMate 复制系统路径。系统的 ruby 位于/usr/bin/ruby
中,它包含在 OSX 默认路径中。如果您安装了 ruby 的自定义版本,那么还要附加该路径,例如在这里我附加了/usr/local/bin
(不要忘记冒号)。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).使用 which ruby 给我的路径不起作用。经过谷歌搜索一段时间后,我找到了一个有效的解决方案,使用rvm的auto-ruby路径作为TM_RUBY变量。
路径是:
/Users/0al0/.rvm/bin/rvm-auto-ruby
当然,这仅适用于您使用 rvm 的情况。
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.