默认的Homebrew的源会经常遇到被Q,或者网络问题导致下载速度非常慢,于是就需要将源更换为国内的源,本次我是将原来的源替换为清华大学的源。
cd "$(brew --repo)" cp -a .git .git_bak git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
接着执行下面的命令
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" cp -a .git .git_bak git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
然后执行
brew update
此时brew的源已经被更换为清华大学提供的源,但是这个只针对brew update,如果要binary的话还需要多做一步:
临时替换
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
长期替换
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
此时大部分brew管理的包都能快速下载,但是brew支持个人存放地址,有可能在s3,那么遇上这些包只能通过$5来下载了~