如果已經安裝過brew,可以重新安裝brew
#卸載brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
#安裝brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
确保自己有/usr/local
目录的权限,如果没有,可以使用如下指令
sudo chown -R 你的用户名 /usr/local/
更換鏡像源
cd /usr/local
#清华镜像源
git remote set-url origin git://mirrors.tuna.tsinghua.edu.cn/homebrew.git
#中科大镜像源
git remote set-url origin http://mirrors.ustc.edu.cn/homebrew.git
#Coding源
git remote set-url origin https://git.coding.net/homebrew/homebrew.git
#三者选其一即可更新
如果以上指令报错,提示
fatal: Not a git repository (or any of the parent directories): .git
可以通过如下指令解决
git init
git remote add origin http://mirrors.ustc.edu.cn/homebrew.git
設置Homebrew Bottles源,編輯~/.bashrc
或~/.zshrc
添加
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles