Ruby – How to use correct ruby in vim ? How to modify $PATH in VIM

osx-lionrbenvrubyvim

I use plain Vim with ruby support on Lion (installed by gist). I am using ruby with rbenv so my path looks like /users/me/.rbenv/shims:…..

From within vim the path is

:!echo $PATH
> usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/fb/.rbenv/shims:....

Even I can create and modify an environment variable:

:let $PATH = "/bar:/foo"
:!echo $PATH
> /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/foo:/bar

paths remains starting with /usr/bin.

So how can I access my ruby 1.9.3 in ~/.rbenv/shims instead the system ruby in /usr/bin ?

Best Solution

This is a known problem introduced by Apple in OS X 10.5 Leopard.

If you are using Bash or Zsh and are using non-interactive shells, you are affected.

Running sudo chmod ugo-x /usr/libexec/path_helper will fix you up, but you should take a look at the article to see why.