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等目录,手动进行删除。