Domanda

I've looked in the BBEdit forums, the RVM documentation and on Stack Overflow - with no joy, so hopefully someone can answer what I hope is a fairly simple question.

Last night I left behind my system Ruby (1.9.2) and installed RVM (I'm on Mac OSX Lion). I am now using the RVM Ruby 1.9.3 on my system as default and everything works fine in the Terminal. However, I use BBEdit to code and want it to use the same RVM Ruby when I hit Command-R to run scripts. Unlike in Textmate, there doesn't seem to be an obvious way to set the PATH to a Ruby installation in BBEdit. Following a related query to the BBEdit support people, I created a .plist file at ~/.MacOSX/environment.plist and tried to set the PATH in there, but it doesn't work. I'm not at home at the moment so if anyone needs to see that .plist file, I can post it later.

È stato utile?

Soluzione

If you're using the BBEdit worksheet you can add do some commands to bring RVM into your environment (See this entry on the bbedit-hints tumblr blog.)

Now, to get the Run command to run the appropriate Ruby, via RVM, the BBEdit documentation says to specify the path to Ruby in the #! line of your script. Just point it to RVM. (Because BBEdit's guess will be the system default Ruby).

The RVM intructions for TextMate talk about the rvm-auto-ruby and wrapper scripts. I'm more familiar with using the wrapper script, so I'll talk about that below.

  1. Create a wrapper script as instructed by that documentation
  2. Use which to find the path for that
  3. Edit the #! line of your script to use that path.

I think the wrapper script will work better in your case, because you might not have a .rvmrc file (since you said you're using 1.9.2 as your RVM default now).

Yes, this is slightly ugly (making these scripts harder to share), and an environmental variable would be nice, but... :-|

Altri suggerimenti

I was in exactly the same situation as the OP three years later.

RVM instructions for TextMate appears now to be defunct. However, on the basis of Ryan's very helpful answer, and by reference to the BBedit tumblr blog cited, I discovered that in my newly installed .rvm directory there's a script at .rvm/bin/ruby-rvm-env which I can point to in the hashbang line of any .rb file and BBedit will then use my rvm installed ruby 1.9.3 version instead of the system (/usr/bin/env) ruby.

#!/Users/username/.rvm/bin/ruby-rvm-env
puts RUBY_DESCRIPTION

Executing this script from within BBedit using the Run command returns this:

ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin11.4.2]

as desired.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top