Homebrew
macOS
Apple M1
ZSH

TIP | The BEST way to install Homebrew (Brew) on Apple Silicon (M1)

Regensburg, Germany - 2021-01-06
Install your favorite macOS package manager on your brand new ARM based Apple Silicon mac the correct way.
Image: Dominik Stötter

Foreword

You'll only get full potential from your M1 Apple Silicon based mac if you use as many libraries and executables that work native as possible. Fortunatelly, the Apple M1 Version of Homebrew is quite simple to install and many formulaes have been compiled already.
The best way to do so is to have 2 homebrew installations: one native apple m1 and one legacy rosetta 2 intel version.
After you've followed this guide, you should first try to install a formular using the native version of Homebrew. If your application is not available yet, you can fallback to the intel version. Both integrate without any problems.
(Left: Apple M1 Native, Right: Intel using Rosetta 2)

1. Install the native Apple M1 version of Homebrew

Make sure your not using the rosetta 2 version of your terminal, to ensure so: - right click on your terminal application - make sure "open with rosetta" is disabled
Installation works as described as on the official homebrew website. You can also just run the following script in the non-rosetta terminal.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. Install intel version of Homebrew

The intel rosetta version installation is a bit different, you could follow the official alternative installation method. You can also just run the following script in the rosetta terminal.
Make sure youre using the rosetta 2 version of your terminal, to ensure so: - right click on your terminal application - make sure "open with rosetta" is enable
cd /opt/local mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
After this step, make sure you reset the terminal rosetta usage. You should disable rosetta 2. Because in the next step we create an alias that automatically calls rosetta with homebrew

3. Add alias for the intel homebrew

At the end you only have to add an alias for your intel based homebrew installation. For example in zsh: nano ~/.zshrc
You only have to add
alias ibrew='arch -x86_64 /opt/homebrew/bin/brew' alias brew='cd /usr/local/Homebrew/bin/brew' # optional, it should be default anyway

Usage

as explained in the first part of this guide, you install something using the native version as normal:
brew install xyz
if that fails, you can go back to the intel version of that formular:
ibrew install xyz

Did you like this article?

Thanks for your feedback!
Dominik Stötter
Fulltime Developer, Amateur Photographer, Horrible Author

Wan·der·lust

/ˈwändərˌləst/
Noun, feminine [the]Desire, joy of hikingInfect yourself with wanderlust by browsing through photography galleries and interesting programming projects. Travel journeys covering infrared, film and digital photography into the world of retro tech, game- and web development.