How do I install Homebrew

What is Homebrew?

Homebrew is a software package management tool based on the Mac OS platform. It has many practical functions such as installation, uninstallation, update, view, search and so on. Package management can be implemented with a simple command, and you don’t have to worry about dependencies and file paths. It is very convenient and quick.

Official website Installation commands
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Copy the code

A problem

Question the status quo

Failed to connect to raw.githubusercontent.com port 443: Connection refused error: Error: 7
Copy the code

If any of the following network errors occur during the installation, the local network is faulty or the GtiHub address cannot be correctly resolved.

Solutions:

  • Step 1: Change the host file

Sudo vi/etc/hosts add 199.232.68.133 raw.githubusercontent.com host file

  • Step 2 Disconnect the wifi from the mobile network and run the command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Copy the code
  • Step 3 Replace the Homebrew source
  1. Replace the homebrew default source
cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
Copy the code
  1. Replace the homebrew – the core source CD “$(brew — repo)/Library/Taps/homebrew/homebrew – core” git remote set – url origin git://mirrors.ustc.edu.cn/homebrew-core.git
  • Step 4: Brew update
brew update
Copy the code
  • Step 5: Set the Bintray image
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
Copy the code

Note: If the second step is stuck, CTRL + C disconnects and re-execute command 2