【问题标题】:Homebrew: PATH env var is modified before installation of Formulae (mercurial will use system python instead of homebrew python)Homebrew:在安装公式之前修改了 PATH env var(mercurial 将使用系统 python 而不是 homebrew python)
【发布时间】:2015-02-14 04:14:36
【问题描述】:

尝试在 Mac OS X 10.9 上使用 Homebrew 来安装 mercurial 并确保它使用的是 homebrew python 版本。

我已将/etc/paths 更新为在/usr/bin 之前列出/usr/local/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/hgshebang(#!)指向系统python/usr/bin/python。
发生这种情况是因为 mercurial python 包安装程序 (distutils) 使用 PATH 变量在 shebang 中硬编码 python 的路径,而不是 #!/usr/bin/env python。

当我检查我的 PATH 环境变量时,我在 /usr/bin 之前看到了 /usr/local/bin,但如果我尝试以交互方式安装 brew 包:brew install -i mercurial 我得到一个带有不同 PATH 变量的 shell,根本没有 /usr/local/bin。

如何安装 mercurial 以确保它使用自制版本的 python ? 我更喜欢一种能够在不断变化的软件包升级中幸存下来的方法。

【问题讨论】:

  • 为什么要 mercurial 使用 Homebrew 的 python?

标签: python macos path mercurial homebrew


【解决方案1】:

默认情况下,公式仅使用系统 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 2011-04-25
    • 2020-09-26
    • 2012-05-07
    • 2013-08-05
    • 2016-07-28
    • 2018-10-08
    相关资源
    最近更新 更多