关于同时使用MacVim和zsh产生PATH读取错误的解决办法

来源:互联网 发布:淘宝韩版女装店铺推荐 编辑:程序博客网 时间:2024/06/05 19:44

直接引用官方解释。


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.

原创粉丝点击