文章目录
Mac上面安装软件包最好的方式是Homebrew,但是Homebrew默认使用的github的源,整体速度慢,而且有时候根本无法访问,所以将其修改成国内的镜像源,我选择了阿里的镜像源。
Homebrew基本
Homebrew主要四个部分组成: brew、homebrew-core 、homebrew-bottles、homebrew-cask:
- brew:源代码仓库
- homebrew-core:核心软件仓库
- homebrew-bottles:预编译二进制软件包
- homebrew-cask:MacOS 客户端应用
查看当brew镜像源
# 指令:
cd "$(brew --repo)" && git remote -v
# 结果:
origin https://github.com/Homebrew/brew.git (fetch)
origin https://github.com/Homebrew/brew.git (push)
查看当前homebrew-core镜像源
# 指令:
cd "$(brew --repo homebrew/core)" && git remote -v
# 结果:
origin https://github.com/Homebrew/homebrew-core.git (fetch)
origin https://github.com/Homebrew/homebrew-core.git (push)
替换成阿里云的镜像源
# 替换brew源,指令:
cd "$(brew --repo)" && git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core源,指令:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 替换homebrew-bottles源,指令:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
# 另外,将bash也替换了
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
刷新源并生效
source ~/.zshrc
source ~/.bash_profile
brew update
其他国内镜像源
# 中科大镜像源
https://mirrors.ustc.edu.cn/brew.git
https://mirrors.ustc.edu.cn/homebrew-core.git
https://mirrors.ustc.edu.cn/homebrew-cask.git
https://mirrors.ustc.edu.cn/homebrew-bottles
# 清华镜像源
https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles