Homebrew For Mac M1



Mac install brew

Popular Mac tool Homebrew has long been used by developers and others for package management on macOS, but as we lamented in our first M1 Mac review, it didn't support Apple Silicon when Apple's new Macs first launched late last year. Now, with the release of Homebrew 3.0.0, that's no longer the case: Homebrew now supports Apple Silicon natively, albeit not with every package.

I'm having what looks like the same issues with brew upgrade and git. I recently upgraded to 11.2 (M1 Mac Mini), realized it broke homebrew, and reinstalled the CLT. I did then brew upgrade, which kicked this error: jonah@M1-Mini % brew update Warning: git 2.30.1 is already installed and up-to-date. Homebrew officially released it for the new apple silicon chip as homebrew 2.6.0. And they made some changes in the commands, In homebrew2.6.0 brew commands replacing all brew cask commands.

The volunteer Homebrew team made the announcement on the Homebrew blog alongside today's release. While the native support is not yet comprehensive, it bridges the gap significantly, and users can still run Terminal via Rosetta 2 to do what they can't yet while running natively on Apple Silicon. The Homebrew blog post says 'we welcome your help' in providing bottles for all packages moving forward.

Here's the full bullet point on Apple Silicon in the Homebrew 3.0.0 release notes:

  • MacOS Homebrew running natively on M1/Apple Silicon/ARM has partial functionality. We recommend installing into /opt/homebrew and forbid installing into /usr/local (to avoid clashing with the macOS Intel install and allow their usage side-by-side). We currently recommend running Homebrew using Intel emulation with Rosetta 2.
  • I've seen three main ways that people are installing homebrew on their M1 Macs. The best method of install should be as smooth as possible while emulating intel architecture, and also should be as easy as possible to switch homebrew to native architecture when that is possible.

Apple Silicon is now officially supported for installations in /opt/homebrew. formulae.brew.sh formula pages indicate for which platforms bottles (binary packages) are provided and therefore whether they are supported by Homebrew. Homebrew doesn’t (yet) provide bottles for all packages on Apple Silicon that we do on Intel x86_64 but we welcome your help in doing so. Rosetta 2 on Apple Silicon still provides support for Intel x86_64 in /usr/local.

Aside from the inability to natively run Windows, the lack of Homebrew was one of the small number of problems we dinged the Apple Silicon Macs for when we reviewed them, and some of our editorial staff have named this as the number one reason they've been holding off on moving to Apple Silicon. Some other users likely share the sentiment, though most macOS users never use tools like this, of course.

Advertisement

In celebrating the update, the Homebrew team gave 'particular thanks' to MacStadium and to Apple. Specifically, the blog post notes that Apple provided the team with Apple Silicon hardware to do the work, and thanks 'Cassidy from Apple for helping us in many ways with this migration.'

Install Brew For Mac M1

Other major changes since the previous Homebrew release, 2.7.0, are listed in the blog post as follows:

  • brew bottle and bottle do blocks use a new syntax format (one :cellar per platform). brew style --fix will autocorrect formulae to this new format. This will allow more bottles to be relocatable.
  • The new HOMEBREW_BOOTSNAP environment variable allows the use of the Bootsnap gem to speed up repeated brew calls. This does not work (yet) on Apple Silicon or using Homebrew’s portable Ruby.
  • Various methods have been deprecated, disabled and removed
  • Bash, fish and zsh completions are generated automatically from the CLI::Parser DSL. This will ensure they are kept up-to-date.
  • brew update better handles upstream branch renames (e.g. from master to main)
  • brew completions is a new command to opt-in to completions provided by third-party taps

Let the great Homebrew migration begin. Yes, Homebrew now has native support for Apple’s ARM64-based M1 chip. The latest version, 3.0.0, released 5 February, will run nicely on your Apple Silicon Mac. There’s a catch, of course. Well, several catches: first, not all of the tools you can install using Homebrew are M1 native yet and, second, Homebrew doesn’t offer explicit migration instructions, that I could find at least.

So I leapt in and hoped for the best. I’ve been using a mix of native Terminal (for tool usage) and Terminal under Rosetta 2 (for tool installation and upgrades), so anything that saves me from maintaining two Termini or temporarily switching the Open using Rosetta option in the utility’s Get Info panel (and usually forgetting to switch it back afterwards) is a bonus. Here’s what I did.

Homebrew For Mac M1

First, re-run the Homebrew installer. On an M1 Mac it will create a new installation under /opt/homebrew (on Intel it’s under /usr/local/bin).

If you’ve been using Homebrew under emulation, you now have two side-by-side installs, so from this point on it’s a matter of working tool by tool, installing an ARM64 versions then removing the x86-64 version. Tools that lack ARM64 versions can stay in the emulated world — just move on to the next one.

For

Edit your .bash_profile or .zshrc file to update any PATH additions or aliases to the new Homebrew installation. For example, alias nano=/opt/homebrew/nano instead of alias nano=/usr/local/bin and export PATH='/opt/homebrew/bin:$PATH' in place of export PATH='/usr/local/bin:$PATH'. But do read on for a solution that works with multiple Macs of different CPU architectures.

I didn’t do this at this point, but were I to do all this again, I would add a further alias: alias oldbrew=/usr/local/bin/brew just to make accessing the old install a little more convenient.

Homebrew

I had side-by-side terminal tabs, one for brew … and the other for /usr/local/bin/brew … as I worked through my installed tools to check they install natively in the first tab and, if so, uninstalling the non-native version from the second tab.

I found that the majority of my previously installed tools have ARM64 versions, including some, like the Go language, which did not when I last checked, a few weeks ago. I can now build my websites with Hugo running on Go natively. Python 3.9 is M1 native, so that saves a lot of bother; I was able to rip out the non-native version entirely. Your mileage will vary according to which tools you use.

For example, I use shellcheck for linting Bash scripts, but it’s not yet native and, as the Homebrew folk warn might be the case, can’t be built from source, at least not using Homebrew. Fortunately, I don’t use shellcheck regularly, so I can afford to wait for native support among all of its many dependencies. It still runs, of course, under Rosetta. I just need to try to re-install it using the native Homebrew every so often, or keep tabs on the Homebrew GitHub repo.

Once you’ve done, it’s worth running brew cleanup to clear out any cruft from each install and then manually deleting any remaining orphaned files and links from /usr/local — look in the various sub-directories, including Caskroom, Cellar, Frameworks, Homebrew, and lib. If all of your Homebrew-installed tools are now native, you may not want to keep the old Homebrew install, and so the first four of these can probably be deleted.

Take care with the contents of /usr/local/bin — you may have tools there that were not installed by Homebrew, or were installed by Homebrew but with fixed install locations. For instance, my command line tools imageprep, pdfmaker and utitool continue to install into /usr/local/bin even when installed by M1-native Homebrew and even though they contain native ARM64 code.

Homebrew

Multiple Homebrews on multiple Macs

Macbook M1 Homebrew

If, like me, you have multiple Macs with different CPU architectures, you can add something like this to your .bash_profile or .zshrc file:

Install Homebrew M1

See Also