Updating Homebrew has been getting stuck recently when installing Homebrew, so I looked for a solution as a record.
Turn off automatic updates
Add the following command to the.zshrc file:
export HOMEBREW_NO_AUTO_UPDATE=true
Copy the code
If it is bash, add it to the.bash_profile file.
Replace mirror source acceleration
When we usually execute brew command to install software, it is related to these three warehouses:
1.brew.git
2.homebrew-core.git
3.homebrew-bottles
Copy the code
Use Ali’s Homebrew mirror source instead to speed things up
Replace the brew. The git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
Copy the code
Restore:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
Copy the code
Replace the homebrew – core. Git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
Copy the code
Restore:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
Copy the code
Replace homebrew-bottles access address
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
Copy the code
To restore HOMEBREW_BOTTLE_DOMAIN, delete the ZSH command. If it is bash, write it in the.bash_profile file.
Reference article: Stopping Homebrew for a long time in Updating Homebrew