Dra*_*SAN 3 linux debian homebrew
当尝试在 Linux 机器上安装 AWS SAM CLI 时,我必须安装 Homebrew/Linuxbrew。AWS 软件包依赖于 python 3,我已经将其安装在我的系统上。在自制程序安装日志的中间,我看到了这一点:
==> Pouring python-3.7.4.x86_64_linux.bottle.tar.gz
==> /home/linuxbrew/.linuxbrew/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/home/linuxbrew/.linuxbrew/Cellar/python/3.7.4
==> /home/linuxbrew/.linuxbrew/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/home/linuxbrew/.linuxbrew/Cellar/python/3.7.4
==> /home/linuxbrew/.linuxbrew/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/home/linuxbrew/.linuxbrew/Cellar/python/3.7.4
==> Caveats
Python has been installed as
/home/linuxbrew/.linuxbrew/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/home/linuxbrew/.linuxbrew/opt/python/libexec/bin
Run Code Online (Sandbox Code Playgroud)
接下来:
$ which python3
/home/linuxbrew/.linuxbrew/bin/python3
Run Code Online (Sandbox Code Playgroud)
这对我来说不太好,因为它之前没有警告过,让我别无选择,而且我比自制软件更信任我的发行版。
我的第一个想法是删除包:
$ brew uninstall python3
Error: Refusing to uninstall /home/linuxbrew/.linuxbrew/Cellar/python/3.7.4
because it is required by aws-sam-cli, which is currently installed.
You can override this and force removal with:
brew uninstall --ignore-dependencies python3
Run Code Online (Sandbox Code Playgroud)
这意味着我不能简单地删除它
现在,安装依赖项是可以忍受的,但如果它替换我的系统本机包,那么我的问题是:
有没有办法告诉 homebrew将来不要弄乱我的系统,并恢复我的本机 python ?
Linuxbrew 将根据需要安装为您安装的软件包提供依赖项的软件包。有时,这些依赖项(或者就此而言,您安装的软件包brew
)将提供与系统上已存在的软件相同的服务或工具。Linuxbrew 不会替换已经通过其他方式安装在系统上的软件,因为它安装的软件是安装在完全独立的位置(按照设计)。
要确保 提供的命令brew
不优先于以其他方式安装的命令,请确保各种 Linuxbrewbin
目录位于您的 中的最后$PATH
,或者至少位于系统上保存“本机”命令的目录之后。bin
我相信 Linuxbrew 将以下内容添加到用户的~/.bash_profile
(或要求用户添加它,我不记得了):
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
Run Code Online (Sandbox Code Playgroud)
(或类似的东西)。
这会导致命令
export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH"
Run Code Online (Sandbox Code Playgroud)
执行,这会将 Linuxbrew 路径添加到$PATH
.
您可以在终端中运行该brew shellenv
命令并将其输出复制到您的~/.bash_profile
文件中(应该有许多export
语句),完全替换那里相应的调用,并将命令更改export PATH
为
export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH"
Run Code Online (Sandbox Code Playgroud)
这可确保默认(非 Linuxbrew)中的命令$PATH
优先于brew
命令。我不能说这是否会破坏任何brew
依赖 Linuxbrew 版本命令的软件包。