Tuesday, April 23, 2013

RVM and vim-rails on Linux

I recently installed Tim Pope's vim-rails plugin (amazing stuff) but pretty quickly ran into a problem running things like the :Rake or :Rscript commands.  I'd get something like the following:

Could not find ZenTest-4.9.1 in any of the sources 

Checking things from the command line showed that ZenTest was, in fact, properly installed.  Finally, the output from a failed :Rake command gave me the clue I needed to resolve this issue:

in `block in materialize':
Could not find gherkin-2.12.0 in any of the sources (Bundler::GemNotFound)
The ruby version vim-rails was using was the default
instead of the project-specific ruby I had specified of

The problem was that I was starting Vim from the system application launcher which is where it picked up the default values for $GEM_HOME since no project was associated.

Simple work-around is to start vim from the project command line and now all the environment settings are correct.

EDIT-1: Just found vim-rvm, again by Tim Pope, which takes care of all of this and then some.

EDIT-2: To get things to work together properly (I'm on RVM 1.19.6 stable and the latest vim-rvm and rim-rails), you have to convert your .rvmrc file to a .ruby-version file using the command:

rvm rvmrc to [.]ruby-version