美文网首页
卸载以及重新安装 brew

卸载以及重新安装 brew

作者: 笔头还没烂 | 来源:发表于2022-07-31 19:42 被阅读0次

1、今天使用 brew 遇到各种奇怪的问题,如:
(1)128 错误,相关日志如下:

Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1` exited with 128.
Error: Failure while executing; `/usr/local/bin/brew tap homebrew/core` exited with 1.

(2)卸载时提示无法定位 Homebrew,相关日志如下:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Failed to locate Homebrew!

于是打算重新安装brew。

2、卸载很简单,只能
cd 到 /usr/local/目录,删掉Homebrew相关的目录即可,命令如下:

rm -rf Cellar Frameworks Homebrew

3、重新安装 Homebrew
小插曲:网上查到很多安装是通过运行下面的命令来安装,实际上使用该条命令,大概率是安装不成功。

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

解决方案:
(1)不使用上面的命令,执行完第二步卸载完旧Homebrew之后,直接通过国内镜像源的方式安装,命令如下:

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

这里一定要执行完第二步把之前旧Homebrew卸载掉,否则会报目录不为空的错误,日志如下:

fatal: destination path '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core' already exists and is not an empty directory.

(2)接下来会提示你选择源,如下,输入数字2,按回车即可。
1、中科大下载源
2、清华大学下载源
3、北京外国语大学下载源
4、腾讯下载源
5、阿里巴巴下载源
(3)安装过程中,如果有Password相关提示,输入电脑用户名的密码按回车继续即可。
(4)安装完,会提示 source 一下环境变量的文件,按提示执行 source 命令,让环境变量生效即可。
(5)最后,如果终端提示用户设置 homebrew-cask 和 homebrew-core 的文件路径设置为 safe.directory,即使用如下命名:

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask

在终端依次复制上面两条命令依次回车确认设置即可。

相关文章

网友评论

      本文标题:卸载以及重新安装 brew

      本文链接:https://www.haomeiwen.com/subject/cdwrwrtx.html