本文使用【中科大镜像】进行安装
2. 设置镜像环境变量(当前终端)
1 2 3 4
| 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" export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles" export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
|
3. 运行安装脚本
1
| /bin/bash -c "$(curl -fsSL https://mirrors.ustc.edu.cn/misc/brew-install.sh)"
|
中途输入密码、按回车,直到出现 Installation successful!
4. 配置 PATH 与镜像(永久生效)
1 2 3 4 5 6 7 8 9 10
| echo 'eval "$(/opt/homebrew/bin/brew shellenv zsh)"' >> ~/.zprofile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zprofile echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.zprofile echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.zprofile echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.zprofile
source ~/.zprofile
|
5. 验证
1 2
| brew --version brew config
|
brew config 中镜像地址显示为 mirrors.ustc.edu.cn 即配置成功。