Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ?

like image 265
fbehrens Avatar asked Mar 24 '12 16:03

fbehrens


1 Answers

I don't use mac or zsh (I am on linux), however I ran into this problem when I ran gvim from the MATE Menu.

I solved it by adding this to my .vimrc:

if $PATH !~ "\.rbenv"
    let $PATH="/home/username/.rbenv/shims:/home/username/.rbenv/bin:" . $PATH
endif

This avoids setting it if you run vim from a terminal, otherwise the rbenv paths would be included twice.

I tried setting the application to run via a terminal, but that didn't help.

like image 116
Jordan Morris Avatar answered Oct 05 '22 23:10

Jordan Morris