Homebrew 安装慢,主要是因为默认使用 GitHub 上的官方源,国内网络访问速度受限,可以通过更换为国内镜像源来提速
中科大(推荐)#
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc腾讯#
/bin/bash -c "$(curl -fsSL https://mirrors.cloud.tencent.com/homebrewbrew/install/install.sh)"
# 装完后Bottles自动指向 https://mirrors.cloud.tencent.com/homebrew-bottles阿里云#
git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc恢复官方源#
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
unset HOMEBREW_BOTTLE_DOMAINPS:
如果之前装过 homebrew-cask 或 homebrew-services,需要把对应仓库的 remote URL 也改掉
运行 brew update 验证速度;若出现 fatal: couldn’t find remote ref 可删掉对应目录后 运行brew tap --force homebrew/core 重新拉取