每次通过Homebrew安装软件,Homebrew会根据源,会比对、下载(或者merge)源仓库到本地,然后根据要下载的软件找到对应的xxx.rb文件,然后再根据rb文件中内容一步步的校验、下载、安装软件。
Homebrew原始源是以下:
# homebrew源 https://github.com/Homebrew/brew.git # homebrew-core源 https://github.com/Homebrew/homebrew-core.git # homebrew-cask源 https://github.com/Homebrew/homebrew-cask.git
国内访问这些源时非常的慢,所以必须替换为国内源,加快速度
# 查看brew.git源 git -C "$(brew --repo)" config --get remote.origin.url # 查看homebrew-core.git源 git -C "$(brew --repo homebrew/core)" config --get remote.origin.url # 查看homebrew-cask.git源 git -C "$(brew --repo homebrew/cask)" config --get remote.origin.url
# 中科大 https://mirrors.ustc.edu.cn/ # 清华 https://mirrors.tuna.tsinghua.edu.cn/ # 阿里 (不推荐,没有home-cask) https://developer.aliyun.com/mirror/
相关信息
以下操作替换完成后
shell# bash
source ~/.bash_profile
# zsh
source ~/.zshrc
shellbrew update
shell# 替换brew.git源
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换 homebrew-core.git源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 替换 homebrew-cask.git源
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
# 配置homebrew-bottles
# 使用bash
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 使用zsh
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
shell# brew.git源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# homebrew-core.git源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# homebrew-cask.git源
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 配置homebrew-bottles
## bash用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
## zsh用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
# brew.git源 git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git # homebrew-core.git源 git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core # homebrew-cask.git源 git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask
zsh 或 bash 注释掉 HOMEBREW_BOTTLE_DOMAIN
配置,前面加#符号就行
本文作者:Silon汐冷
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!