2026-02-05 12:54:58
homebrew,挂梯子也提示网络受限了(自建梯子实在太慢了,害得我又买了新的梯子),没办法,只好切换国内源,结果,因为版本太旧了(PS:毕竟10年前的机子)。然后,索性重装brew吧。多少年没有折腾brew了,幸好有AI。以下记录一下流程。反正,年终总结也不想写,就水一篇记录吧。
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_NO_AUTO_UPDATE=1
# 配置 brew 主仓库
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 配置 homebrew-core(此时已设置环境变量,不会再报错)
git -C "$(brew --repo homebrew/core)" remote set-url origin "${HOMEBREW_CORE_GIT_REMOTE}"
# 配置 homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
# 配置二进制包镜像加速
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
# 检查环境变量是否生效
echo $HOMEBREW_CORE_GIT_REMOTE
# 清除旧缓存
rm -rf ~/Library/Caches/Homebrew/api
# 执行更新
brew update