直接引用官方解释。
For zsh users
Rename the /etc/zshenv file to /etc/zprofile
If MacVim appears to use the wrong PATH
variable, you may have run into a zsh configuration problem. Try the following:
$ sudo mv /etc/zshenv /etc/zprofile
NOTE: If the system already has a /etc/zprofile
, make sure you merge the two files instead of overwriting /etc/zprofile
.
The problem is caused by /etc/zshenv
, which (somewhat erroneously) resets the PATH
for every zsh instance, not just login shells. MacVim, running in a non-interactive shell, gets a PATH
variable that has the OS X system paths but is missing user-defined paths.
If the above alone does not work, there is an additional step involved. Set your PATH
(or any other variable you may need) in ~/.zprofile
. To do that, assuming you have your PATH
set in ~/.zshrc
, use the command
$ cat ~/.zshrc | grep "export PATH" >> ~/.zprofile
There is a caveat: when using Terminal.app
, the variables present in .zprofile
and .zshrc
will contain duplicate items. To avoid confusion add typeset -U name_of_the_variable
to your .zshrc
.