[英]Homebrew: PATH env var is modified before installation of Formulae (mercurial will use system python instead of homebrew python)
尝试在Mac OS X 10.9上使用Homebrew来安装mercurial,并确保它使用的是homebrew python版本。
我已经将/etc/paths
更新为在/usr/bin
之前列出/usr/local/bin
/usr/bin
。
使用brew install python
安装了python 2.7.9,python可执行文件位于/usr/local/bin/python
,这是/usr/local/Cellar/python/2.7.9/bin/python
的符号链接。
当我键入which python
或python -V
我得到的是自制python版本。
稍后,当我运行brew install mercurial
,已安装的文件/usr/local/bin/hg
shebang( #!
)指向系统python /usr/bin/python
。
发生这种情况的原因是,Mercurial python软件包安装程序(distutils)使用PATH变量在shebang中而不是#!/usr/bin/env python
来硬编码python的路径。
当我检查PATH环境变量时,我会在/usr/bin
/usr/local/bin
之前看到/usr/local/bin
,但是如果尝试以交互方式安装brew软件包: brew install -i mercurial
我会得到一个带有不同PATH变量的shell,而没有/usr/local/bin
。
如何安装mercurial以确保它将使用python的自制版本? 我更喜欢这样一种方法,该方法也可以在日常升级中幸免。
默认情况下,该公式仅使用系统Python。 您可以绕过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.