我无法在MacOS Apple Silicon上卸载brew

7
如此提到了此处,我键入以下命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"但好像没有起作用...

之后我再输入which brew,返回/usr/local/bin/brew

再次输入/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

显示如下:

/bin/bash: line 236: /opt/homebrew/bin/brew: No such file or directory Failed to locate Homebrew!

所以我不知道该怎么卸载brew。

我的终极目标是在尝试安装brew包时不出现此错误:

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)! Please create a new installation in /opt/homebrew using one of the "Alternative Installs" from:
https://docs.brew.sh/Installation You can migrate your previously installed formula list with: brew bundle dump

我现在使用的是Apple Silicon的Mac,但我曾经使用过Intel Mac。

编辑1: 我快速查看了一下 uninstall.sh 脚本,此处

看起来我的问题是由我的操作系统安装引起的,因为我是从基于Intel的MacOS时间机器备份中进行安装的。问题在于 uninstall.sh 脚本是根据当前操作系统卸载homebrew的。因此,该脚本只能卸载我需要的ARM homebrew,而不能卸载我想要摆脱的Intel homebrew...

也许我应该尝试更改探测我是否有ARM CPU的代码行,以使脚本认为我有基于Intel的Mac,但我不知道这会不会给我的电脑带来混乱...

我很惊讶没有太多关于这个问题的答案,因为我认为我不是唯一一个从基于Intel的Mac切换到基于ARM的Mac和Time Machine。

编辑2: 我尝试用自己的命令arch -x86_64 ./uninstall_brew.sh卸载Homebrew (我不知道这是否危险),但我不知道它是否有效...

以下是命令的输出:

user@MacBook-Pro % arch -x86_64 ./uninstall_brew.sh
Warning: This script will remove:
/Users/user/Library/Caches/Homebrew/
/usr/local/Caskroom/
/usr/local/Cellar/
/usr/local/bin/brew -> /usr/local/bin/brew
Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] y
==> Removing Homebrew installation...
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
Warning: Failed to delete /usr/local/Caskroom
rm: /usr/local/Caskroom: Permission denied
Warning: Failed to delete /usr/local/Cellar
rm: /usr/local/Cellar: Permission denied
==> Removing empty directories...
Password:
==> /usr/bin/sudo /usr/bin/find /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var /usr/local/Caskroom /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks -name .DS_Store -delete
==> /usr/bin/sudo /usr/bin/find /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var /usr/local/Caskroom /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks -depth -type d -empty -exec rmdir {} ;
==> Homebrew uninstalled!
The following possible Homebrew files were not deleted:
/usr/local/.com.apple.installer.keep
/usr/local/Frameworks/
/usr/local/Homebrew/
/usr/local/bin/
/usr/local/etc/
/usr/local/git/
/usr/local/include/
/usr/local/lib/
/usr/local/man/
/usr/local/opt/
/usr/local/remotedesktop/
/usr/local/sbin/
/usr/local/share/
/usr/local/var/
You may wish to remove them yourself.

这个回答解决了你的问题吗?如何卸载Homebrew? - chenrui
OP有一个类似的问题,但是答案中给出的链接是404错误。所提供的解决方案告诉我要查找的答案在常见问题解答中,但我仔细查看了并没有找到它。 - DigitalRomance
你对这些文件夹有权限吗?你能手动删除它们吗? - Vega
我有管理员权限,但我有点害怕使用它们,以防对计算机造成危险。 - DigitalRomance
非常感谢你提出这个问题!我经历了和你一样的过程,一度感到迷茫不知如何解决。现在问题已经解决了! - undefined
显示剩余2条评论
5个回答

10

10
为了 M1 处理器,我需要像这样微调它:PATH=/opt/homebrew:$PATH arch -arm64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" - Starsky
@Starsky的调整对我起了作用。只需要注意一点,可能需要进入/opt/homebrew文件夹并删除脚本无法删除的内容。脚本运行后还有一些文件夹剩下。 - m1771vw

3

我在我的M1 MBP上遇到了类似的问题,我发现更改卸载脚本中的卸载路径可能有效。

首先,我下载了一个卸载脚本的本地副本。

curl -O https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh

然后在本地运行脚本,并设置路径为/user/local(这是Intel Mac上Homebrew的默认路径)

/bin/bash uninstall.sh --path=/usr/local

但它完成时出现了2个警告,我不确定它们是什么

Warning: Failed during: /usr/bin/sudo rmdir /usr/local
Warning: Homebrew partially uninstalled (but there were steps that failed)!
To finish uninstalling rerun this script with `sudo`.
The following possible Homebrew files were not deleted:
/usr/local/Cellar/
/usr/local/Frameworks/
/usr/local/Homebrew/
/usr/local/bin/
/usr/local/etc/
/usr/local/include/
/usr/local/lib/
/usr/local/opt/
/usr/local/sbin/
/usr/local/share/
/usr/local/texlive/
/usr/local/var/
You may wish to remove them yourself.

无论如何,我都会手动删除这些文件。

(这是我第一次在Stack Overflow上回答问题。希望这可以帮到你!)


1
一个简单而容易的解决方法就是在卸载命令前面加上arch -x86_64,这样应该能正常工作。

1

我遇到了相同的问题。 解决方法就是从你的 Mac 上删除 Git 配置。

命令:rm -rf ~/.gitconfig

执行完该命令后,尝试安装 Homebrew。

命令:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

在安装 Homebrew 后,请安装 Brew Git。

命令:brew install git 然后配置你的 GitHub 账户。

谢谢。


0
看那个 `uninstall.sh`,有一个地方会根据处理器类型设置 `homebrew_prefix_default`,还有使用信息说:
-p, --path=PATH  Sets Homebrew prefix. Defaults to ${homebrew_prefix_default}.

看起来你可以通过传递--path=...选项来覆盖默认位置,使用你想要的路径,即脚本为Intel机器选择的路径,即/usr/local

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接