$PATH variable not properly set in gvim/MacVim when it is opened from the finder

后端 未结 4 1424
再見小時候
再見小時候 2020-12-08 22:07

I am using MacVim (basically gvim for the mac).

If I open macvim from the command line then my $PATH variable will be properly set.

If I ope

相关标签:
4条回答
  • 2020-12-08 22:17

    I had this same issue but it only appeared after setting my default shell to zsh like so

    export SHELL=/bin/zsh
    

    It seems that there is a bug in the OS X zsh setup. The work around in brief is to merge /etc/zshenv into /etc/zprofile. In my case I didn't have a /etc/zprofile so just moving over the file did the trick:

    sudo mv /etc/zshenv /etc/zprofile

    This post describes the solution in more detail.

    0 讨论(0)
  • 2020-12-08 22:19

    For me, simply creating a new symbolic link from .zprofile to .zshrc did the trick:

    ln -s ~/.zshrc ~/.zprofile
    
    0 讨论(0)
  • 2020-12-08 22:21

    The difference in the PATHs probably has something to do with the difference between a login shell (logging in) and a non-login shell (bringing up a console).

    From the bash man page:

    When bash is invoked as an interactive login shell ... it looks for ~/.bash_profile...

    When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc...

    What I did to get around this issue was to add the following code to my ~/.bash_profile, telling it to source my ~/.bashrc if it exists:

    if [ -f ~/.bashrc ]; then
        . ~/.bashrc
    fi
    
    0 讨论(0)
  • 2020-12-08 22:32

    The place to set environment variables on the Mac for GUI applications (those started via loginwindow, the Finder, etc.) is ~/.MacOSX/environment.plist

    Alternately in MacVim you can choose to launch vim processes in a login-shell (look in the preferences).

    For more info see this post.

    0 讨论(0)
提交回复
热议问题