[英]Homebrew: PATH env var is modified before installation of Formulae (mercurial will use system python instead of homebrew python)
Trying to use Homebrew on Mac OS X 10.9 to install mercurial and make sure it's using homebrew python version. 尝试在Mac OS X 10.9上使用Homebrew来安装mercurial,并确保它使用的是homebrew python版本。
I've updated /etc/paths
to list /usr/local/bin
before /usr/bin
. 我已经将
/etc/paths
更新为在/usr/bin
之前列出/usr/local/bin
/usr/bin
。
Installed python 2.7.9 using brew install python
, the python executable is located at /usr/local/bin/python
which is a symlink to /usr/local/Cellar/python/2.7.9/bin/python
. 使用
brew install python
安装了python 2.7.9,python可执行文件位于/usr/local/bin/python
,这是/usr/local/Cellar/python/2.7.9/bin/python
的符号链接。
When I type which python
or python -V
I'm getting the homebrew python version. 当我键入
which python
或python -V
我得到的是自制python版本。
Later, when I run brew install mercurial
the installed file /usr/local/bin/hg
shebang ( #!
) points to the system python /usr/bin/python
. 稍后,当我运行
brew install mercurial
,已安装的文件/usr/local/bin/hg
shebang( #!
)指向系统python /usr/bin/python
。
This is happening because mercurial python package installer (distutils) is using the PATH variable to hardcode the path to python in shebang instead of #!/usr/bin/env python
. 发生这种情况的原因是,Mercurial python软件包安装程序(distutils)使用PATH变量在shebang中而不是
#!/usr/bin/env python
来硬编码python的路径。
When I check my PATH environment variable I see /usr/local/bin
before /usr/bin
, but if I try to install a brew package interactively: brew install -i mercurial
I get a shell with a different PATH variable without /usr/local/bin
at all. 当我检查PATH环境变量时,我会在
/usr/bin
/usr/local/bin
之前看到/usr/local/bin
,但是如果尝试以交互方式安装brew软件包: brew install -i mercurial
我会得到一个带有不同PATH变量的shell,而没有/usr/local/bin
。
How can I install mercurial to make sure it will use the homebrew version of python ? 如何安装mercurial以确保它将使用python的自制版本? I prefer a way that would survive mercurial package upgrades as well.
我更喜欢这样一种方法,该方法也可以在日常升级中幸免。
By default the formula only uses system Python. 默认情况下,该公式仅使用系统Python。 You can bypass Superenv (which sanitizes PATH) and it should pick up whatever is in PATH when building from source:
您可以绕过Superenv(清理PATH),并且从源代码构建时,它应该获取PATH中的所有内容:
$ brew reinstall mercurial --build-from-source --env=std
$ head -n 1 /usr/local/bin/hg
#!/usr/local/opt/python/bin/python2.7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.