e.g.,
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/bin:~/bin:/usr/local/Cellar/python3/3.2.3/bin
$ vim
:! echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:~/bin:/usr/local/Cellar/python3/3.2.3/bin
I expected them to be the same. Why are they different?
If it makes a difference, here is my shell, vim version and OS version:
$ echo $SHELL
SHELL=/usr/local/bin/zsh
$ /usr/local/bin/zsh --version
zsh 5.0.0 (x86_64-apple-darwin12.0.0)
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 20 2012 13:16:02)
Compiled by root@apple.com
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.8.2
BuildVersion: 12C60
(Mountain Lion)
There are many similar questions on SO and SU.
Your shell executes different *rc files depending on the arguments its given at launch time. Therefore, you need to setup Vim so that it launchs your shell with the right arguments.
The following helps in bash, I'm almost certain there's a similar flag in zsh.
See
$ man zsh
for the right flag and the right execution order.From this SO answer
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:
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.
I was not able to resolve this with zsh, and ended up using bash for my vim shell.
Here's what I did:
ln -s .zshrc .bashrc
set shell=bash
to my .vimrc fileand now my vim command-line PATH is equal to my zsh shell PATH.