问题描述
我已经按照 RVM 最佳实践为我的项目设置了 RVM 并制作了单独的 gemset.一>.现在在 TextMate 中运行测试文件不起作用,我有阅读此处该怎么做.问题是它不起作用,因为指南希望我只有一个 gemset(他们称之为Rails3").我通常一次打开 2-3 个项目(使用不同的 gemset),所以我不能有效地使用这种方法.
I have set up RVM and made individual gemsets for my projects as per the RVM best practices. Now running a test file in TextMate dosen't work and I have read here what to do. The problem is that it won't work because the guide expects me to have just one gemset (they call it "Rails3"). I normally have 2-3 projects open at a time (using different gemsets) so I can't effectively use this approach.
有没有人解决过这个问题?
Have any of you solved that problem?
推荐答案
我发现 RVM 包装器方法非常有缺陷,并且正如您发现的那样,除非您做了很多工作,否则它根本不适用于 gemset繁琐的设置.
I've found the RVM wrappers method to be very buggy, and as you've discovered it doesn't work at all with gemsets unless you do a lot of tedious setup.
我使用以下脚本作为 TM_RUBY
取得了一些成功:
I've had some success using the following script as TM_RUBY
:
#!/bin/bash
base_dir=${TM_PROJECT_DIRECTORY:-$PWD}
cd $base_dir
exec $MY_RUBY_HOME/bin/ruby $*
只要您在 TextMate 项目中并且项目根目录中有 .rvmrc
文件,它就会在 .rvmrc 中指定的 Ruby 版本和 gemset 中运行您的代码代码>.
cd
确保 RVM 发现 .rvmrc
.
As long as you're in a TextMate project and you have a .rvmrc
file in the project root it will run your code in the Ruby version and gemset specified in the .rvmrc
. The cd
makes sure RVM discovers the .rvmrc
.
将上面的代码放入 ~/bin/textmate_ruby_wrapper
,然后转到 Preferences > Advanced > Shell Variables 并将 TM_RUBY
设置为相同的路径.
Put the code above into ~/bin/textmate_ruby_wrapper
and then go to Preferences > Advanced > Shell Variables and set TM_RUBY
to that same path.
这篇关于在 TextMate 中使用带有不同 gemset 的 RVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!