TextMate, rvm and TM_RUBY

回眸只為那壹抹淺笑 提交于 2019-11-29 15:11:55

问题


In the TextMate RVM instructions the text it says to set TM_RUBY to /Users/wayne/.rvm/bin/textmate_ruby and in the image it shows it set to rvm-auto-ruby. I decided to set it to rvm-auto-ruby thinking that it would use RVM's default Ruby version.

When running Command R in the RSpec.bundle having TM_RUBY set to rvm-auto-ruby will result in a load error. When you set it to textmate_ruby it works.

The only problem here is that TextMate doesn't always use the default version of Ruby since it's hardcoded in that file.

/Users/jspooner/.rvm/bin/textmate_ruby:

#!/usr/bin/env bash

if [[ -s "/Users/jspooner/.rvm/environments/ruby-1.9.2-head" ]] ; then
  source "/Users/jspooner/.rvm/environments/ruby-1.9.2-head"
  exec ruby "$@"
else
  echo "ERROR: Missing RVM environment file: '/Users/jspooner/.rvm/environments/ruby-1.9.2-head'" >&2
  exit 1
fi

So two questions:

  1. What should TM_RUBY=rvm-auto-ruby actually do?
  2. Is there a way to have TextMate use the RVM default?

回答1:


See your other, similar, question Rspec bundle is broken in TextMate and rvm.


To help others chasing this same issue, the solution seems to be at: RVM / Textmate doesnt recognize .rvmrc Options.

Basically you replace the ~/.rvm/bin/textmate_ruby soft link with a file. This is what I did:

  1. cd ~/.rvm/bin
  2. mv textmate_ruby old.textmate_ruby
  3. Create a shell script called textmate_ruby in the same directory to replace the soft-link, using the following contents:
    
    

    !/usr/bin/env sh

    source ~/.rvm/scripts/rvm cd . exec ruby "$@"
  4. chmod +x textmate_ruby

Before doing this change I'd see my system Ruby's version (1.8.7) displayed if I did CMD+R to run the following script in TextMate:

puts RUBY_VERSION

Evaluating the script using CMD+CNTRL+SHIFT+E gave me 1.9.2.

After switching to use that script both point to Ruby 1.9.2, so at least there's some consistency now. I don't see TextMate tracking my currently set RVM Ruby version yet; Instead it's using the default version set in RVM: rvm use 1.9.2 --default. This is still a step forward because I can control which Ruby TextMate uses by adjusting my --default.

If you decide you want to revert later, just rename, or delete, the script and reverse step 2 above.




回答2:


Setting TM_RUBY to your-path/rvm-auto-ruby

http://rvm.io/integration/textmate/

should load whatever ruby and gemset is indicated in the .rvmrc file located in the project and if none default to rvm default. I just got this working and it is very smooth. I did need to get the latest version of rvm

rvm get head

to make it work and restart Textmate. Hope that helps.



来源:https://stackoverflow.com/questions/4317933/textmate-rvm-and-tm-ruby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!