原因是 Homebrew 每次安装包的时候默认开启了自动更新的设置。可通过配置关闭掉。
# 在 .bash_profile 或者 .zshrc 添加一行配置(具体看自己终端默认 Shell 是 bash 还是 zsh)
# 1. 打开 (二选一)
$ vim ~/.bash_profile
$ vim ~/.zshrc
# 2. 在对应文件,添加一行配置,并保存
export HOMEBREW_NO_AUTO_UPDATE=true
# 3. 刷新配置(二选一)
$ source ~/.bash_profile
$ source ~/.zshrc
还有一个比较狗血的方法就是:ctrl + c 跳过。但还是修改配置的方式一劳永逸。
具体思路是替换 Homebrew 镜像源。
替换 brew.git
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
替换 homebrew-core.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
重置 brew.git
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git
重置 homebrew-core.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
好吧,替换之后,我还是觉得慢。

