How to install homebrew on MAC M1

Time:2021-4-19

Most commonly used commands

Search software: brew search package name

Installation software: brew install package name

Uninstall software: brew install package name

Error resolution

Question 1: curl: (7) failed to connect to http://raw.githubusercontent.com port 443: Connection refused “error

resolvent:

Open www.ipaddress.com Website queryraw.githubusercontent.com The real IP address of the host

Open the / etc / hosts file and add a record


185.199.108.133  raw.githubusercontent.com 

Question 2:If the following error occurs in brew install, use arch – arm64 brew install package name for installation

Create installation directory

The homebrew installation script will install the program to / usr / local / homebrew by default, which is the installation path on Intel chip architecture, while the M1 chip needs to be installed under / opt / homebrew /.


sudo mkdir -p /opt/homebrew
sudo chown -R $(whoami) /opt/homebrew

Download the homebrew package and unzip it to the / opt / homebrew directory


curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

If the download is slow, you can download it directly through https://github.com/Homebrew/brew/tarball/master Or download it locally, copy it to / opt directory, and then extract the compressed package to / opt / Hometree directory

cp /opt
Tar XZ package name -- strip 1 - C homebrew

Add the path to the path environment variable


vim ~/.bash_profile
#In. Bash_ New in profile
export PATH=$PATH:/opt/homebrew/bin;
#Save exit
#Refresh to take effect
source ~/.bash_profile

Modify source

cd "$(brew --repo)"
git clone https://mirrors.ustc.edu.cn/brew.git
 
 
cd "$(brew --repo)/Library/Taps/homebrew"
 
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
 
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
 
Brew update

Other image addresses:

Official image of homebrew:
brew: https://github.com/Homebrew/brew
core: https://github.com/Homebrew/homebrew-core
cask: https://github.com/Homebrew/homebrew-cask

Tsinghua University Image:
brew: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
core: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
cask: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

Image of China University of science and technology
brew: https://mirrors.ustc.edu.cn/brew.git
core: https://mirrors.ustc.edu.cn/homebrew-core.git
cask: https://mirrors.ustc.edu.cn/homebrew-cask.git

Finally, we can download the software

Brew install - s package name

So far, this article about how to install homebrew for Mac M1 is introduced. For more information about installing homebrew for M1, please search previous articles of developer or continue to browse the following articles. I hope you can support developer more in the future!