从 finder 打开 gvim/MacVim 时 $PATH 变量未正确设置
我正在使用 MacVim(对于 mac 来说基本上是 gvim)。
如果我从命令行打开 macvim,那么我的 $PATH
变量将被正确设置。
如果我通过使用查找器点击打开 macvim,则 $PATH
变量将无法正确设置。
谁能给我一些见解吗?
注意:我知道我的路径至少有一部分是在 ~/.bashrc
中设置的,但我不确定其余部分在哪里设置。
示例:
如果我从终端打开 macvim:
% gvim basic.tex
然后在 MacVim 中我会:
:!echo $PATH
/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Applications/MacVim.app/Contents/M
acOS:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/texbin:/usr/X11R6/bin
这是正确的路径。
当我用鼠标打开文件时(在查找器中)
当我走时:
:!echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin
它给了我一条小路径。为什么?
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 open macvim via point and click with the finder, the $PATH
variable will NOT be properly set.
Can anyone give me some insight?
Note: I know at least part of my path is set in ~/.bashrc
, but I am not sure where the rest of it is set.
Examples:
If I open macvim from the terminal:
% gvim basic.tex
And then in MacVim I go:
:!echo $PATH
/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Applications/MacVim.app/Contents/M
acOS:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/texbin:/usr/X11R6/bin
This is the right path.
When I open the file with the mouse (in finder)
When I go:
:!echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin
It gives me a little path. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我也遇到了同样的问题,但它只在将我的默认 shell 设置为 zsh 后才出现,看起来
OS X zsh 设置中有一个错误。简而言之,解决方法是将
/etc/zshenv
合并到/etc/zprofile
中。就我而言,我没有/etc/zprofile
因此只需移动该文件就可以解决问题:sudo mv /etc/zshenv /etc/zprofile
这个 post 更详细地描述了该解决方案。
I had this same issue but it only appeared after setting my default shell to zsh like so
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.
对我来说,只需创建一个从 .zprofile 到 .zshrc 的新符号链接就可以了:
For me, simply creating a new symbolic link from .zprofile to .zshrc did the trick:
设置环境变量的地方
在 Mac 上用于 GUI 应用程序(通过登录窗口启动的应用程序、
Finder 等)是
~/.MacOSX/environment.plist
或者,在 MacVim 中,您可以选择在登录 shell 中启动 vim 进程(查看首选项)。
有关详细信息,请参阅此内容发布。
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.
路径的差异可能与登录 shell(登录)和非登录 shell(调出控制台)之间的差异有关。
从 bash 手册页:
我为解决此问题所做的是将以下代码添加到我的
~/.bash_profile
中,告诉它获取我的~/.bashrc
if它存在: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:
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: