Search code examples
macosenvironment-variablesosx-mountain-lionmacvimrbenv

Vim path configuration in OS X


I'm trying to set $PATH variable in MacVim to the same value it has in a Terminal.

From these sources I wrote in ~/.zprofile

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
eval "$(rbenv init -)" # this makes rbenv work

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
echo $PATH >> ~/path # for debugging purposes

And this are my results, in ~/path $PATH is correctly defined:

/usr/local/heroku/bin:/Users/pills/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

But when I do !echo $PATH in MacVim I get a twisted value:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/heroku/bin:/Users/pills/.rbenv/shims

I saw from https://superuser.com/a/47166/145603 how $PATH is set, but I don't get why I'm having this behaviour. Can someone help me with this?


Solution

  • You're using zsh, it seems. In recent OS X releases, Apple ships a misconfiguration in the form of /etc/zshenv. You should fix that with

    sudo mv /etc/zshenv /etc/zprofile
    

    If you still have issues with misconfigured PATH in Vim, try setting this in ~/.vimrc:

    set shell=bash  " avoids munging PATH under zsh
    let g:is_bash=1 " default shell syntax
    

    If you do this, ensure that your ~/.bashrc is also configured for rbenv the same way your ~/.zprofile is.

    For more information about which shell initialization files get sourced when, refer to the Unix shell initialization guide