一、查看brew的安装目录
cd "$(brew --repo)"
pwd
二、查看当前源
cd "$(brew --repo)"
git remote -v
可以看到当前brew的国内源是中科大的镜像
三、设置homebrew的源
Homebrew主要由4个部分组成:
brew: 源代码仓库
homebrew-core: 核心软件仓库
homebrew-bottles: 预编译二进制软件包
homebrew-cask: MacOS客户端应用
以 USTC(中科院)镜像为例:
- 替换 Homebrew 源
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
- 切换 Homebrew Core 源
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
- 切换 Homebrew Cask 源
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
设置源的参考文档:
http://mirrors.ustc.edu.cn/help/brew.git.html
根据使用的shell,这里以zsh为例:
编辑 ~/.zshrc 添加如下内容
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
export HOMEBREW_BREW_GIT_REMOTE=https://mirrors.ustc.edu.cn/brew.git
export HOMEBREW_CORE_GIT_REMOTE=https://mirrors.ustc.edu.cn/homebrew-core.git
调用source命令使配置文件生效,然后更新 brew
source ~/.zshrc
brew update
四、查看homebrew的版本
brew --version