ZSH, Vim, Ruby and rbenv

 Nov 1, 2013

Updated: 2014/11/01
This post also applies after upgrading to OS X Yosemite. I had to do the same thing all over again to get Vim to start using my rbenv versions of Ruby.

Over the last year I’ve gradually pushed myself towards Vim and can now say I’m a complete convert. I generally live inside Vim as much as possible, running most of my tools from its command line rather than jumping out to the terminal. As a general rule the only time I switch to a command line is to run something with a lot of output (read something I’m piping to less or git diff etc)

I’m also an avid fan of z-shell over the normal bash.

After upgrading to Mavericks I found I had to re-install all my homebrew recipes to get them recompiled correctly with the new OS. Not really unexpected, but it did trip me up in one area. Running Ruby inside Vim.

Even with all my $PATH set up correctly, and every other part of my system recognising my rbenv versions of Ruby, Vim stubbornly refused to use anything by the Apple supplied version. Normally this wouldn’t be a problem seeing as Mavericks comes with ruby 2.0.0-p247, but all my gems have installed via the rbenv versions and therefore can’t be found by the system version.

As it turns out, the only FAQ on Tim Pope’s rbenv.vim README gave the answer and I’m just popping it here to act as a future reminder (both to myself and anyone who stumbles across this post).

You’re using zsh on OS X, aren’t you? Move that stupid /etc/zshenv to /etc/zshrc.

I already seemed to have an /etc/zshrc file as well as a /etc/zshenv so I just renamed the file to stop zsh using it and everything started working.

sudo mv /etc/zshenv /etc/zshenv.bak

Thanks Tim.

To be honest, I don’t use Tim’s plugin for rbenv, but I’m going to give it a try seeing as it pretty much fits the bill for the way I work.