如果使用 Homebrew 官方的安装脚本进行安装,会发现安装十分缓慢,我们可以更换安装脚本中设置的仓库路径来加速安装过程。
首先先将官方的脚本下载下来,命名为 install:
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> install使用 vim 或者其他文本编辑器打开 install 脚本,修改:
BREW_REPO一行为:
BREW_REPO = "https://mirrors.ustc.edu.cn/brew.git".freeze保存后重新使用 ruby 运行脚本:
ruby ./install脚本会飞速安装,然后停顿在 homebrew-core 的下载过程,此时使用 ^C 快捷键强制结束进程,将 homebrew-core 手动下载到 homebrew 安装目录:
git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1完成上面的步骤之后,使用如下命令完成换源:
# change brew source
cd $(brew --repo)
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# change brew-core source
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git完成换源之后,再执行更新指令一次:
brew update看看是不是比以前快了许多呢?