Installation of Homebrew arm

According to the official plan, ARM Homebrew must be installed in the /opt/ Homebrew directory instead of /usr/local/homebrew. Because the official installation script has not been updated, you can run the following command to manually install it:

Switch to the /opt directory
cd /opt 
Create the Homebrew directory
sudo mkdir homebrew
# Change the user to which the directory belongs
sudo chown -R $(whoami) /opt/homebrew 
Install Homebrew Arm
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Copy the code

Homebrew X86 installation

Installing homebrew for x86 is similar to the previous method, except that you specify the x86 architecture by prefixing the installation command with arch-x86_64:

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

If the installation is slow using the official image, you can use the domestic image:

#Use domestic sources to install the X86 version of Homebrew
arch -x86_64 /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Copy the code

Note: If the download fails, you can try a different source.

Distinguish between the two versions of Homebrew

Once it was installed, we had two versions of Homebrew on our computers, one arm and one x86. To avoid two Homebrews that conflict, what I do is I “rename” the two Homebrews by adding the following to

~ /.zshrc:

# x86
export PATH="/usr/local/bin:$PATH"
alias  abrew='arch -x86_64 /usr/local/bin/brew'

# arm
export PATH="/opt/homebrew/bin:$PATH"
alias  brew='/opt/homebrew/bin/brew'
Copy the code

After saving the Settings, run the source ~/.zshrc command to make the configuration take effect.

Brew install XXX is the arm version of Homebrew and abrew install XXX is the x86 version of Homebrew.

Homebrew change source

Due to the use of foreign source installation software will be slow, let’s change the source for Homebrew, here I use is the source of the University of Science and Technology.

Replace the source of Arm version:

#Replace the brew. The git
cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git

#Replace the homebrew - core. Git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
Copy the code

Change the X86 version:

#Replace the brew. The git
cd "$(abrew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git

#Replace the homebrew - core. Git
cd "$(abrew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
Copy the code

Finally, add the following content in ~/.zshrc to replace Homebrew bottle source, Arm version and X86 version are the same:

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
Copy the code

After saving and exiting, run source ~/.zshrc, and then call brew config and abrew config to check whether the source has been replaced successfully!

Software that supports arm architecture

To see which software supports the ARM architecture, check this website:

doesitarm.com/

Problems encountered during software installation

1. Stuck

==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'.Copy the code

Use Control + C to interrupt the installation and execute the following command

cd "$(brew --repo)/Library/Taps/"
mkdir homebrew && cd homebrew
git clone git://mirrors.ustc.edu.cn/homebrew-core.git
Copy the code

2. Each upgrade is required

export HOMEBREW_NO_AUTO_UPDATE=true
Copy the code

Enter the above command on the command line, or add it to.zshrc