Homebrew hasn’t yet finished adapting Mac models with Apple Silicon CPUs, and the installation tutorial is a bit confusing, so I’m putting together this article to help you.

For progress information, check out the instructions on GitHub.

This article briefly introduces the method of installing Homebrew on the M1 chip MAC, and suggests that the partners with the following article to read and install.

Homebrew Quick Installation Tutorial

Install the ARM version of Homebrew

The ARM version of Homebrew needs to be installed in the /opt/ Homebrew path. In the early days, you needed to manually create a directory to execute the command.

Direct Execution:

/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

Then also need to set the environment variable, the specific operation steps are as follows, be sure to read carefully.

Echo $SHELL echo $SHELL echo $SHELL echo $SHELL

  • /bin/bash= >bash= >.bash_profile
  • /bin/zsh= >zsh= >.zprofile

If you encounter an invalid environment variable, it is recommended to go back and look at the terminal type and make the correct Settings.

Starting with MacOS Catalina(10.15.x), Mac uses ZSH as the default Shell and uses.zprofile, so the command is:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

If it’s MacOS Mojave or lower and you haven’t configured ZSH yourself, use.bash_profile:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
eval "$(/opt/homebrew/bin/brew shellenv)"

Use Zsh as the default Shell on the Mac

Install the X86 version of Homebrew

Since many packages currently do not support the ARM architecture, we can also consider using the x86 version of Homebrew.

To execute the command in X86 mode, add arch-x86_64 before the command, such as:

arch -x86_64 /bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

Multi-version coexistence

If you have both ARM and X86 installed, you will need to set aliases to separate commands from each other.

Also add.zprofile or.bash_profile:

As to which file to operate, please refer to the previous description of the terminal type. If there is similar text below, keep doing the same.

alias abrew='arch -arm64 /opt/homebrew/bin/brew'
alias ibrew='arch -x86_64 /usr/local/bin/brew'

Abrew, ibrew can be customized according to your preferences.

Then update the file by executing the source ~/.zprofile or the source ~/.bash_profile command.

Set up the mirror

Note: The installation script in this article sets the University of Science and Technology of China source image, if you want to do the samecaskandbottlesPlease click the comments section below to select the code to execute.

For a more detailed tutorial, see the previous article: Homebrew Quick Installation Tutorial

Modify the brew in the “$(brew –repo)” code according to the actual situation.

If you want multiple versions to co-exist or use aliases, replace the brew keyword with an alias name, such as abrew, ibrew, etc.

# brew git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git # core git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git # cask git -C "$(brew --repo Homebrew/cask) "remote set - origin url https://mirrors.ustc.edu.cn/homebrew-cask.git # bottles for ZSH and below 2 choose 1 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zprofile source ~/.zprofile # bottles For bash and above 2 choose 1 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' > > ~ /. Following source ~/.bash_profile

Refer to the “Setting up Mirrors” section of the Homebrew Quick Installation tutorial for details on the mirror setup.

Communication and feedback

If you have any questions, you can give feedback in the following ways:

  • WeChat group (recommended)
  • GitHub Issue
  • comments

If the tutorial is useful, please thumb up to let me know