就像这里提到的https://docs.brew.sh/FAQ#how-do-i-uninstall-homebrew我输入/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:没有这样的文件或目录Homebrew定位失败!
所以我不知道该怎么卸载brew.
我的最终目标是在我尝试安装一个brew包时不出现这个错误:
错误:无法在Intel默认的ARM处理器上安装Homebrew前缀(/usr/本地)!请在/opt/homebrew目录下创建一个新安装使用"替代安装"之一;from:
https://docs.brew.sh/Installation您可以迁移先前的安装公式列表:brew bundle dump
我现在用的是苹果芯片的Mac电脑,但我以前用的是英特尔的Mac电脑。
编辑1:我在这里快速查看了uninstall.sh
脚本https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
我的问题似乎是由我的操作系统安装引起的,因为我是从基于intel的MacOS时间机备份中进行的。问题是uninstall.sh
脚本被编程为根据当前操作系统卸载自制软件。所以这个脚本只能卸载我需要的ARM自制程序,不能卸载我试图摆脱的Intel自制程序…
也许我应该试着改变检测我有一个ARM CPU的代码行,使脚本认为我有一个基于英特尔的Mac,但我不知道它是否会给我的计算机带来混乱…
我很惊讶没有很多关于这个问题的答案,因为我不认为我是唯一一个用时间机器从基于英特尔的Mac切换到基于arm的Mac的人。
编辑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.
试运行:PATH=/usr/local/bin:$PATH arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
在这里找到答案:https://github.com/Homebrew/discussions/discussions/3437
我在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
但它完成了两个警告,我不确定它们是什么
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.
无论哪种方式,我手动删除这些文件。
(这是我第一次回答关于堆栈溢出的问题。希望对你有帮助!
我也面临同样的问题。解决方案就是从你的mac上删除你的git配置。
命令:rm -rf ~/.gitconfig
执行命令后尝试安装brew。命令:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装homebrew后,安装brew git命令:brew install git
然后配置你的GitHub配置文件。
谢谢。
一个简单而容易的解决方案就是在卸载命令前使用arch -x86_64
,它应该可以正常工作。
查看uninstall.sh
,有一个地方homebrew_prefix_default
根据处理器类型设置,并且有使用信息说:
-p, --path=PATH Sets Homebrew prefix. Defaults to ${homebrew_prefix_default}.
所以看起来你可以通过传递--path=...
选项和你想要的路径来覆盖默认位置,也就是脚本为英特尔机器选择的路径,即/usr/local
。