The most direct way to specify a ruby
is to give its full pathname in the :!
command (instead of relying on whichever ruby
is found first in the PATH directories):
To use the Ruby at /path/to/your/preferred/ruby
:
:!/path/to/your/preferred/ruby %
To use RVM-installed ruby-1.9.2-head
:
:!~/.rvm/bin/ruby-1.9.2-head %
To use RVM-installed ruby-1.9.2-head
with your rails3-dev
gemset:
:!~/.rvm/bin/ruby-1.9.2-head@rails3-dev %
So your map command might end up like this:
:map ,t :w\|:!~/.rvm/bin/ruby-1.9.2-head@rails3-dev %<cr>
It is also usually possible to adjust the effective value of the PATH environment variable so that your desired ruby
is the first one found, but it may not always be as simple as you might like. Specifically, the :!
commands are processed by the shell configured by the shell Vim option (:set shell?
to see its value). The configuration files for that shell may modify the PATH value that Vim gives the shell (compare Vim’s PATH (:echo $PATH
) to the PATH that :!
commands end up using (:!echo $PATH
) to see if your shell’s configuration files might be adjusting the PATH).
You might try modifying the PATH that Vim and its children use like this:
:let $PATH = $HOME . '/.rvm/wrappers/ruby-1.9.2-head@rails3-dev:' . $PATH
You should check the effective PATH with :!echo $PATH
and :!which ruby
to find whether your shell is further modifying the PATH (maybe :set shell=/bin/sh
if you have this problem).
Note: I have never seen this particular use of RVM’s wrapper directories, future versions of RVM may break it. The normal usage is to create a wrapper and invoke it directly out of ~/.rvm/bin
(similar to the first part of this post) instead of putting ~/.rvm/wrapper/whatever
in the PATH.