How to install Brew automatically in China (domestic address)
1, Automatic script (all domestic addresses)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
/bin/bash -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
If successful, as shown above.
2, Manual operation
Step 1: delete the previous brew and create a new Homebrew folder with the command
sudo rm -rf /usr/local/Homebrew sudo mkdir /usr/local/Homebrew
Enter the computer power on password after entering (the password will not be displayed, and enter the normal enter after entering).
Step 2: git clone
sudo git clone https://mirrors.ustc.edu.cn/brew.git /usr/local/Homebrew
After entering, you will be prompted to receive objects: XX% to wait for the download to complete.
Step 3: delete the original brew and create a new one
sudo rm -f /usr/local/bin/brew sudo ln -s /usr/local/Homebrew/bin/brew /usr/local/bin/brew
Step 4: create core folder and clone
sudo mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core sudo git clone https://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
(the following two sentences do not have to be operated) if brew cask is needed, run:
sudo mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask sudo git clone https://mirrors.ustc.edu.cn/homebrew-cask.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Step 5: delete the brew environment and recreate it:
sudo rm -rf /usr/local/var/homebrew/ sudo mkdir -p /usr/local/var/homebrew sudo chown -R $(whoami) /usr/local/var/homebrew
Last step: get permission to run update (two sentences run separately)
sudo chown -R $(whoami) /usr/local/Homebrew brew update
Display Already up-to-date. It indicates success, and then make the final setting (domestic download source)
Finally, set the environment variable, run the following two sentences, and restart the terminal:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
Extension description: visible but not visible
1. In each step https://mirrors.ustc.edu.cn/ It can be replaced with any of the following:
If the source is still slow after replacement, replace the stable network, such as 4G hotspot of mobile phone or network cable.
2. Read the comments and say there is no git. Run the following sentence and click Install in the pop-up window. (if you are prompted for error, it indicates that it has been installed)
3. brew has a self-test program. If there is a problem with self-test, try:
4. How to view a directory: (search "brew" under bin to make sure there is only one)