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

发布于 2024-11-18 04:24:32 字数 953 浏览 2 评论 0 原文

编辑:我找到了一个解决方案,您可以在下面的我的回答中阅读它。

我在 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

葮薆情 2024-11-25 04:24:32

如果您使用 RVM,也许您可​​以尝试输入:

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

并在您的文本伙伴首选项中将此路径设置为名为“TM_RUBY”的 shell 变量,如我的屏幕截图

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

希望有帮助:)

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 :)

╰◇生如夏花灿烂 2024-11-25 04:24:32

在首选项/高级/shell 变量下,添加一个名为 TM_RUBY 的新变量。并输入 ruby​​ 二进制文件的绝对路径。

您可以通过打开终端并输入以下内容来获取后者:

which 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
待天淡蓝洁白时 2024-11-25 04:24:32

如果您使用 which ruby​​ 并且 TextMate 显示 exec: rbenv: not find,您需要输入:rbenv which ruby​​。在 TM_RUBY 中使用该路径。

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.

百变从容 2024-11-25 04:24:32

解决方案实际上非常简单,不需要特殊的安装过程。正如 TextMate 博客 中提到的,您所需要做的就是告诉 Text mate你的路径变量。 TextMate 默认情况下不加载此信息。在“首选项”中,转到“变量”选项卡,添加变量 PATH(如果尚不存在),其值为 $PATH:/usr/local/bin 。这告诉 TextMate 复制系统路径。系统的 ruby​​ 位于 /usr/bin/ruby 中,它包含在 OSX 默认路径中。如果您安装了 ruby​​ 的自定义版本,那么还要附加该路径,例如在这里我附加了 /usr/local/bin (不要忘记冒号)。

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

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).

Updating the PATH variable in TextMate2 preference pane

小梨窩很甜 2024-11-25 04:24:32

使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文