Skip to content
dudleyf edited this page Dec 7, 2011 · 7 revisions

Using RVM

RVM set the GEM_HOME and GEM_PATH environment variables which causes Vim to try loading gems from the GEM_HOME, which results in errors even if the gems are actually installed in system ruby. For example the Hammer plugin requires github-markup which is installed automatically by Janus, but GEM_HOME causes rubygems to try loading the gem from that folder instead of the rubygems default folder.

Unless someone come up with a better solution, the only reasonable solution I was able to find is to wrap vim and all the aliases with a function that unset these environment variables, here's a function that does this which you can add to your .bashrc or .zshrc (do not forget to call it after defining it!)

# Define Vim wrappers which unsets GEM_HOME and GEM_PATH before
# invoking vim and all known aliases
#
# @author Wael Nasreddine <wael.nasreddine@gmail.com>
function define_vim_wrappers()
{
  vim_commands=(
    eview evim gview gvim gvimdiff gvimtutor rgview
    rgvim rview rvim vim vimdiff vimtutor xxd mvim
  )

  for cmd in ${vim_commands[@]}; do
    cmd_path=`/usr/bin/env which -a "${cmd}" 2>/dev/null | grep '^/'`
    if [ -x "${cmd_path}" ]; then
      eval "function ${cmd} () { (unset GEM_HOME; unset GEM_PATH; $cmd_path \$@) }"
    fi
  done
}

Call it with

define_vim_wrappers
Clone this wiki locally