MAC_homebrew安装、镜像更换及卸载

homebrew安装

homebrew中文官网
homebrew安装及卸载脚本

执行install.sh安装脚本

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

可能出现的问题:

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

原因:raw.githubusercontent.com网站连接不上

解决办法:
查询raw.githubusercontent.com对应ip并将映射添加到hosts文件中:
1.使用https://www.ip138.com查询ip
在这里插入图片描述
2.将香港对应的ip提交到/etc/hosts文件中

sudo vi /etc/hosts
// 添加下面一行并保存
151.101.76.133  raw.githubusercontent.com

重新执行第一步安装命令,可进行安装
在这里插入图片描述
使用brew help出现相关参数即说明安装成功。
在这里插入图片描述

更换镜像

更换原镜像为中科大镜像
中科大镜像网站

对于 bash 用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

对于 zsh 用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

这里将HOMEBREW_BOTTLE_DOMAIN对应的地址变量写入全局配置文件中。
使用export -p查看配置

➜  ~ export -p
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

使用brew update命令查看安装情况

➜  ~ brew update
Already up-to-date.

即完成安装。

卸载

执行下列语句进行卸载

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

另外,需要自己排查
/usr/local/Homebrew等目录,手动进行删除。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章