97

I'm on the M1 MacBook. This is the error when I try to install Homebrew:

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

Homebrew is not (yet) supported on ARM processors!
Rerun the Homebrew installer under Rosetta 2.
If you really know what you are doing and are prepared for a very broken experience you can use another installation option for installing on ARM:
  https://docs.brew.sh/Installation

So how do I "Rerun the Homebrew installer under Rosetta 2."?

Paul R
  • 195,989
  • 32
  • 353
  • 519
Watson
  • 2,099
  • 2
  • 8
  • 11

8 Answers8

105

Got an answer from a developer in the Homebrew github https://github.com/Homebrew/brew/issues/9173

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

Use this to install packages:

arch -x86_64 brew install <package>

If you have not yet installed Rosetta 2 to emulate Intel CPUs on ARM Macs, you will get the error arch: posix_spawnp: /bin/bash: Bad CPU type in executable. Prompt a Rosetta 2 installation with:

softwareupdate --install-rosetta
Jacob Ford
  • 2,300
  • 1
  • 18
  • 34
Watson
  • 2,099
  • 2
  • 8
  • 11
  • 2
    thanks for this. got my dev environment back up well, the equivalent of it. I've been running stuff using vagrant and virtualbox. but virtualbox is not working. so I was able to recreate it using homebrew. picked up the Mac mini M1 and it's been running great. runs cool and fans have yet to spin. can't say the same for my 2016 MBP i7. it works but hot and audible. – w1n78 Nov 18 '20 at 15:15
  • and if this does not work? the one-line install command fails with the same error message ("unsupported on m1") when I prefix `arch -x86_64`. any hints? i seem to be the only one with the problem. also - tried running the terminal with rosetta (same), and yes I did install rosetta. any help appreciated! – flypenguin Dec 13 '20 at 19:12
  • okay, out of a hunch I changed my terminal login shell to `bash` instead of whatever is default in big sur (probably zsh). then it worked. took me just 3 days, maybe it helps someone else :) – flypenguin Dec 13 '20 at 19:23
  • 1
    @flypenguin Did you run `softwareupdate --install-rosetta` first? If so, did you try restarting the Terminal and/or your machine after that? It's possible that macOS doesn't recognize that it can now run x86_64 code until you do that. – Nathan2055 Dec 28 '20 at 03:23
  • I had been struggling for a day or so on my new mac mini m1 to make PHP work with SQL Server. This did the trick. To install SQL Server extensions for PHP, follow the instructions found here https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15&viewFallbackFrom=sql-server-ver17, but make sure to use the prefix brew by arch -x86_64. – Benjamin Mar 29 '21 at 14:46
46

Another option is by going into your applications in Finder, select Terminal and press cmd(⌘)+I and check the "Open using Rosetta" option.

Sorry if the formatting is off, first time posting a solution.

Alan Weng
  • 556
  • 4
  • 13
  • 13
    Note that this will default `Terminal.app` to _always_ emulate Intel CPU. Might be useful if you are transitioning and want all your old scripts to work, but may not be what you want. – Jacob Ford Nov 18 '20 at 03:53
  • 1
    I'm trying to run pod install using rosetta on a new mac, and it doesn't work. Same errors. I wonder why this is – Jacobo Koenig Nov 18 '20 at 21:50
  • 9
    An improvement to this answer - that's been widely covered - is to duplicate Terminal.app and select "Open using Rosetta" for that copy. Use the Intel emulation version for Homebrew. Gold. https://www.macrumors.com/2020/11/18/apple-m1-mac-tidbits/ https://osxdaily.com/2020/11/18/how-run-homebrew-x86-terminal-apple-silicon-mac/ – Jonathan Dagle Nov 23 '20 at 13:37
  • 1
    This is not the solution I'm going with, but I do think it's a helpful suggestion. Thank you. :) – Justin Force Dec 08 '20 at 17:40
  • @JonathanDagle I tried it, but I still get the same error message. So strange... – Houman Dec 10 '20 at 19:47
  • 1
    I figured it out. You have to have Rosetta 2 first installed before you duplicate and mark it as Open with Rosetta. Otherwise it won't work – Houman Dec 10 '20 at 19:56
  • @Hourman Glad you figured that out. It makes sense — maybe? :) – Jonathan Dagle Dec 13 '20 at 02:49
29

I have two instances of brew installed, the Intel version that runs using Rosetta2 and which installs to /usr/local/bin and the Arm version that runs natively and installs to /opt/homebrew/bin. Now it is all working, I do not have to start iTerm using Rosetta.

I have these aliases to reach the two versions.

ibrew='arch -x86_64 /usr/local/bin/brew'
mbrew='arch -arm64e /opt/homebrew/bin/brew'

I have the native version in my path first:

path=( /opt/homebrew/bin /opt/homebrew/opt /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin )

Now I can try mbrew search and mbrew install. If they work, I am good to go with a native program. For example:

mbrew install ag

If brew fails I try building from source, with verbose output, e.g.

mbrew install -sv rust

Be warned, this takes a while and may still fail.

If it still fails, (and mbrew install -sv go results in a segmentation fault for me) I have two choices. Use ibrew search and ibrew install to get the Intel build instead, or examine the verbose output and look for problem dependencies. In some cases an install -s on the dependencies is enough to get the native brew to work.

I must stress that native brew always prints this warning

Warning: You are running macOS on a arm64 CPU architecture.
We do not provide support for this (yet).
Reinstall Homebrew under Rosetta 2 until we support it. 

So proceed at your own discretion.

For completeness, and assuming you have iTerm2, Rosetta2 and the Xcode command line tools installed, I did this to install brew under Rosetta (with credit to all those who have posted on this page before me):

  1. Copy the installed iTerm2.app application to iRosetta2.app
  2. Press command+I to Get Info for iRosetta.app, click Open Using Rosetta2
  3. Run iRosetta2 and use this command from https://brew.sh

Like so

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)
alias ibrew='arch -x86_64 /usr/local/bin/brew' # put this in ~/.zshrc

And I did this to install native brew, taken from other contributors to Stack Overflow and the Homebrew alternative installation site, using iTerm2 without Open Using Rosetta2

mkdir ~/homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
sudo mv ~/sudo mv homebrew /opt
mbrew='arch -arm64e /opt/homebrew/bin/brew' # for .zshrc
export PATH="/opt/homebrew/bin:/opt/homebrew/opt:$PATH" # also for .zshrc

Edit

Time has passed and I have changed the architecture to arm64e following Fernando García Redondo observation. Now the warning about Arm architecture not supported has gone and Rust and Go install with problems and without compiling from source. I assume the good people at Homebrew have been working hard over Christmas. Thanks!

Edit Feb 21

The Homebrew team have announced that they support Apple silicon. So I wondered if I could delete my aliases and just use brew to install for Apple silicon. The short answer is no! if you run brew from /usr/local without the arch -x86_64, it complains that /usr/local is reserved as the Intel default prefix and using /opt/homebrew is required. So I will retain my two aliases and try mbrew first and only use ibrew if the native brew fails.

Nigel Davies
  • 1,118
  • 1
  • 8
  • 25
  • 1
    Hi @nigel. I am new to macOS here. When should you use 'arm64' and when 'arm64e' after 'arch'? 'man arch' returns 'arm64e' as M1 and 'arm64' as default arm64. – Fernando García Redondo Jan 03 '21 at 19:15
  • @FernandoGarcíaRedondo your observation is a good one. I have modified my alias and reinstalled using mbrew. It works better now, possibly because the people at Homebrew have made improvements. – Nigel Davies Jan 04 '21 at 21:45
11

After I installed Rosetta, I added an alias so I can use brew install <package> as I would normally.

alias brew='arch -x86_64 brew'

I agree with everyone else in that you need to add the arch -x86_64 in front of the original command so thought to include that alias to help anyone finding this thread in the future

Echen
  • 137
  • 7
  • Why not alias it to brew, for intel brew. Then you can add mbrew="arch -arm64 /opt/homebrew/bin/brew" later to get native builds? – Nigel Davies Dec 18 '20 at 14:04
  • Hi Nigel, I'm not sure what you mean. Could you clarify? I believe I am aliasing it to brew but are you suggesting to alias to ibrew instead as a distinction between intel and arm? – Echen Dec 22 '20 at 06:21
  • Hi Echen, Please see my detailed answer below. – Nigel Davies Dec 23 '20 at 12:50
8

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" worked on my new M1 Mac

sudha
  • 81
  • 2
6

Do below

now try az login. you are good to go

6

The easiest way to run Homebrew is with Rosetta 2.

1. Duplicate Your Favourite Terminal for Rosetta

Find your favourite terminal, right-click to duplicate it, and rename it for easier identification. In this example, I'm using the default Terminal app on Big Sur 11.2.1.

duplicate-terminal-right-click-option

duplicate terminal rosetta m1 homebrew

Right-click the Terminal Rosetta and go to Get Info to check the Open using Rosetta option.

enter image description here

2. Install Homebrew

Open the rosetta terminal and run the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Running this command will ask you for the password, and then it will provide you with the information of what all it will install and which new directories it will create.

3. Using Homebrew

Once HomeBrew is installed, you can start using it to install your required packages into the M1 Mac.

Run the following command to get brew help:

brew help

To install a package, you can run the following command:

brew install packagename

That’s all about installing and getting started with Homebrew on Apple M1 Macs.

Khairul Anwar
  • 532
  • 6
  • 10
-1

You can change the setting of Terminal to launch it using Rosetta. Go to your Application/Utilities folder, right click on the Terminal App and check the tick box 'Open using Rosetta'

But to be honest, I have Homebrew installed without Rosetta. Just removed the x86 version yesterday and installed a fresh version without Rosetta.

0x2c4
  • 21
  • 5