We often run with multiple ruby versions and often I have to recompile YCM when I switch as sometimes I get errors like segfaults or can't find ruby.

I was wondering, how do I get YCM to compile by linking to ruby via the shim so that no matter which version of ruby is running it should (theoretically) link to the current one?

Or is there a better (read correct) way to deal with this for YCM?


1 Answer 1


Thanks @mMontu, I found a solution in an issue tracker, the answer isn't to get ycm to compile with the current ruby but rather to ensure the correct version that YCM is compiled with is set before opening Vim, you can do that by following the steps found here.

The specific steps are:

  1. If you use Homebrew to install vim, you should update Homebrew: brew update or update with your package manager specific upgrade update command.

  2. If you already installed vim use Homebrew, remove it: brew remove vim

  3. Use the system Ruby to compile and install vim:

    • for rvm do rvm <system|ruby version> do brew install vim
    • for rbenv install the only plugin and then do rbenv only -r <ruby version> -c ""brew install vim
  4. Make a function to acces vim:

    • for rvm do:

    function vim() { cmd="exec /usr/local/bin/vim $@" rvm $GLOBAL_RUB_VERSION do "$cmd"; }

    • for rbenv do:

    function vim() { cmd="exec /usr/local/bin/vim $@" rbenv only -r $GLOBAL_RUB_VERSION -c "$cmd"; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.