使用 阿里云 的 Homebrew 镜像源进行加速
如果你没有更换过镜像源,执行 brew 命令安装应用的时候,跟以下 3 个仓库地址有关:
- brew.git
- homebrew-core.git
- homebrew-bottles
- 通过以下操作将这 3 个仓库地址全部替换为阿里云提供的地址。
更换 brew.git
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
更换 homebrew-core.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
执行上述命令之后,请执行 brew update 命令
- 此时可以执行 brew config 命令,查看配置信息:
➜ homebrew-core git:(master) brew config
HOMEBREW_VERSION: 2.2.1
ORIGIN: https://mirrors.aliyun.com/homebrew/brew.git
HEAD: 2fe99bd9823fadea1cf918b1ed8366de7f40d336
Last commit: 4 weeks ago
Core tap ORIGIN: https://mirrors.aliyun.com/homebrew/homebrew-core.git
Core tap HEAD: 5e7788416506b0b03df9e587586bdc71bfc39845
Core tap last commit: 4 weeks ago
HOMEBREW_PREFIX: /usr/local
CPU: dodeca-core 64-bit kabylake
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
Clang: 11.0 build 1100
Git: 2.21.0 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 1.8.0_202
macOS: 10.15.2-x86_64
CLT: N/A
Xcode: 11.3
更换 homebrew-bottles
这与你当前 macOS 系统使用的 shell 版本有关系,执行以下命令查看 Shell 版本:
➜ homebrew-core git:(master) echo $SHELL
/bin/zsh
根据版本不同,会输出 2 种结果,/bin/zsh 或 /bin/bash,根据类型进行操作即可
/bin/zsh
➜ homebrew-core git:(master) echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
➜ homebrew-core git:(master) source ~/.zshrc
/bin/bash 结果
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile