简体   繁体   English

在TextMate中使用具有不同gemsets的RVM

[英]Using RVM with different gemsets in TextMate

I have set up RVM and made individual gemsets for my projects as per the RVM best practices . 我根据RVM最佳实践设置了RVM并为我的项目制作了单独的gemsets。 Now running a test file in TextMate dosen't work and I have read here what to do. 现在在TextMate中运行测试文件不起作用,我已经在这里阅读了该怎么做。 The problem is that it won't work because the guide expects me to have just one gemset (they call it "Rails3"). 问题是它不起作用,因为指南希望我只有一个gemset(他们称之为“Rails3”)。 I normally have 2-3 projects open at a time (using different gemsets) so I can't effectively use this approach. 我通常一次打开2-3个项目(使用不同的gemsets),所以我无法有效地使用这种方法。

Have any of you solved that problem? 有没有人解决过这个问题?

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. 我发现RVM包装器方法非常有问题,而且你发现除非你做了很多繁琐的设置,否则它根本不适用于gemsets。

I've had some success using the following script as TM_RUBY : 我使用以下脚本作为TM_RUBY取得了一些成功:

#!/bin/bash

base_dir=${TM_PROJECT_DIRECTORY:-$PWD}
cd $base_dir
exec $MY_RUBY_HOME/bin/ruby $*

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 . 只要您在TextMate项目中并且项目根目录中有.rvmrc文件,它就会在.rvmrc指定的Ruby版本和gemset中运行您的代码。 The cd makes sure RVM discovers the .rvmrc . cd确保RVM发现.rvmrc

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. 将上面的代码放入~/bin/textmate_ruby_wrapper ,然后转到Preferences> Advanced> Shell Variables并将TM_RUBY设置为相同的路径。

I've found this solution which is even simpler. 我发现这个解决方案更简单了。 Under the TextMate Preferences - Advanced - Shell Variables: 在TextMate首选项 - 高级 - 外壳变量下:

Set your GEM_HOME : 设置你的GEM_HOME

env | grep GEM_HOME | awk '{ sub(/GEM_HOME=/, ""); print }'

Set your GEM_PATH : 设置你的GEM_PATH

env | grep GEM_PATH | awk '{ sub(/GEM_PATH=/, ""); print }'

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

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