127

I use the latest Apple M1 chip processor. And I keep getting errors while application installation.

say.,

brew install openjdk@11
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump

Need help with exact steps to follow.

Paul R
  • 202,568
  • 34
  • 375
  • 539
Prashanth Sams
  • 16,250
  • 19
  • 96
  • 119

10 Answers10

231

For what it's worth, before installing Homebrew you will need to install Rosetta2 emulator for the new ARM silicon (M1 chip). I just installed Rosetta2 via terminal using:

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

This will install rosetta2 with no extra button clicks.

After installing Rosetta2 above you can then use the Homebrew cmd and install Homebrew for ARM M1 chip: arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Once Homebrew for M1 ARM is installed use this Homebrew command to install packages: arch -x86_64 brew install <package>

emonz
  • 2,336
  • 1
  • 8
  • 4
  • 1
    I have already installed HomeBrew in this path /opt/homebrew/ and installed Nginx and PHP too which is working properly. Does this break if I execute the above command? – Maniprakash Chinnasamy Feb 16 '21 at 16:55
  • 22
    After this command : `/usr/sbin/softwareupdate --install-rosetta --agree-to-license` I get `Installing Rosetta 2 on this system is not supported.` – Omar Shabab Mar 19 '21 at 03:21
  • 10
    I am also facing the same issue is there any other workaround for this `Installing Rosetta 2 on this system is not supported.` – Vikas Sharma Apr 12 '21 at 18:21
  • 3
    Uncheck run with rosetta in terminal and it can be install Rosetta 2. It works for me – Duc Nguyen Jul 23 '21 at 02:56
  • i unchecked rosetta in terminal, but it still get that error @DucNguyen – Hung Vu Jul 24 '21 at 06:54
  • Quit terminal and then try again. – user3305074 Aug 12 '21 at 18:54
  • 1
    I'm wondering what the difference is between this solution and the one @court3nay provided - there 2 instances of brew is installed, one using rosetta, another one for ARM - this one here only uses rosetta, so will I be missing out on anything if I use this option only? – benomatis Aug 20 '21 at 08:59
  • 2
    Add an alias `alias brew86="arch -x86_64 /usr/local/homebrew/bin/brew"` to your `.zshrc` for future convenience – rahul Oct 13 '21 at 07:13
  • For those getting the response: "Permission denied @ rb_file_s_symlink", try: $ sudo chown -R $(whoami) $(brew --prefix)/* – rsaha77 Dec 25 '21 at 19:50
  • hey, thanks for this btw. After adding your 3rd command to install my package, which in this case is rgdbs - https://rgbds.gbdev.io/install/macos - getting the following error: `/usr/local/Cellar/libpng/1.6.37 is not a valid keg` Any ideas? – RandomDeveloper Dec 31 '21 at 08:16
  • 2
    I had the error `Installing Rosetta 2 on this system is not supported.`, and solved it by doing the following: 1. I had previously set up my terminal to 'run with Rosetta', so I decided to duplicate it and rename the new application 'Rosetta-Terminal' (optional, but good if you need rosetta for other things) 2. Unchecked 'run with rosetta' in 'get info' of 'Terminal'. 3. Quit and Reopen Terminal... ran the command and it worked – Gnardog Mar 03 '22 at 17:15
  • @Gnardog thank you so much, this indeed worked from my end as well! – Ram Fattah Apr 02 '22 at 05:00
88

Homebrew needs to be installed in two places on Apple silicon: in /usr/local for rosetta-emulated (Intel) code, and /opt/homebrew for ARM64. These are somewhat hard-coded and the /opt/homebrew one MUST be used for ARM code, as it stands today, and is non-negotiable. However, it's easy enough to install and you can follow the general instructions on the official docs. You open a Rosetta shell first.

% arch -x86_64 zsh
% cd /usr/local && mkdir homebrew
% curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

Later, to install tools under intel you can use the arch command per-command or open a zsh terminal as above.

arch -x86_64 /usr/local/homebrew/bin/brew install sometool

For the ARM architecture, you don't need to use arch but you do need to use the full path of the homebrew command.

/opt/homebrew/bin/brew install sometool

You could rename the brew commands to something like brew86 and brewARM to help keep them separate.

court3nay
  • 1,697
  • 9
  • 15
  • "You could rename the brew commands to something like brew86 and brewARM to help keep them separate" - How exactly to do this? – indojin Jan 06 '21 at 08:21
  • 12
    @indojin You can use a ZSH alias. By adding `alias brew86="arch -x86_64 /usr/local/homebrew/bin/brew"` and `alias brewARM="/opt/homebrew/bin/brew"` to your `~/.zshrc` file – SamJakob Jan 07 '21 at 07:08
  • I also used the alias. I wonder why this is not standard for the homebrew installation... ;) – Martin Feb 05 '21 at 20:32
  • 1
    How do you know if want to install something to 86 or ARM? – Ty Conway Mar 12 '21 at 16:34
  • Thanks. The approved answer did not work for me for some reason. But after I ran the commands including CURL. I have been able to install the package. – PARITOSH THAPLIYAL Apr 07 '21 at 12:44
29

Just use:

arch -arm64 brew install package-name

replace 'package-name' with the package you want to install.

Jeff Hogg
  • 327
  • 3
  • 4
  • This was the simple answer for my 2021 M1 Max running on Monterey 12.1. If new to nginx, read the output of the install. You do need to start the service and by default it's listening on port 8080 on version 1.21.6_1 of nginx. – sday Mar 12 '22 at 16:02
  • 1
    didn't work for me to upgrade node – Dashiell Rose Bark-Huss Mar 18 '22 at 04:32
25

Did a temporary fix by enabling Open using Rosetta option in the terminal app from Utilities folder.

However, it would be great to know the actual solution for this question to use the native way.

enter image description here

Prashanth Sams
  • 16,250
  • 19
  • 96
  • 119
18

This issue with new macbook pro M1 chip

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!

For Resolve follow below steps

Step1

$ brew bundle dump

Step2

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

Step3 Edit file below

$ vi ~/.bashrc or vi ~/.zshrc

Edit below line in above file

export PATH=/opt/homebrew/bin:$PATH

manoj patel
  • 856
  • 6
  • 9
  • 3
    Problem with this is that in the end you will eventually need to use both homebrew versions. The answer should at least point out the consequences of this change... ;) – Martin Feb 05 '21 at 20:34
  • my answer based on M1 chips and my experience – manoj patel Apr 05 '21 at 14:15
  • 2
    Seconding @Martin's note above. Regardless of your experiences, it'd be good to make folks aware. – jmealy Dec 24 '21 at 06:16
13

Run this in the terminal it fixes the issue

eval "$(/opt/homebrew/bin/brew shellenv)"

gandharv garg
  • 841
  • 7
  • 15
3

Homebrew is now available for the new apple M1 chip at https://docs.brew.sh/Installation. The script installs in a new location, ‘/opt/homebrew’ instead of ‘/usr/local’ which requires that you implement a couple lines of script after the install, substituting your username. You can copy/paste from the comments in your install. Just don’t skip these steps.

==> Next steps:
- Add Homebrew to your PATH in /Users/[username]/.zprofile:
    echo 'eval "$(/opt/homebrew/bin/brew [username])"' >> /Users/[username]/.zprofile
    eval "$(/opt/homebrew/bin/brew [username])"

Note: This works for a clean install of Homebrew on a new machine. If you have already installed an old version of Homebrew and got it working, I believe you need to uninstall that first -or- you may find this a quicker work-around http://blog.wafrat.com/homebrew-on-mac-with-m1/. Not tested.

2

First run this command:

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

then it will ask you a question, hit return, then wait for the installation to be completed. After than run this command:

brew bundle dump
Amir Hassan Azimi
  • 8,357
  • 5
  • 31
  • 40
  • This works but it's missing some steps. After you run the first command make sure you run the two commands brew asks you to run. And after running `brew bundle dump` move the BrewFile created by `brew bundle dump` into `opt/homebrew`. From that directory, run `brew bundle install`. `brew bundle dump` doesn't install the packages, it just creates a BrewFile that tells brew what packages it should install when you run `brew bundle install`. Like a package.json file in node.js. – Dashiell Rose Bark-Huss Mar 18 '22 at 18:11
2

This also may occur if you are trying to run your command in IntelliJ Terminal. Just try to run in (Regular) Terminal.

cmlonder
  • 2,180
  • 19
  • 31
  • This happened to me trying to install homebrew from the VSCode terminal. Just use a Regular terminal. – Mark Hkr May 26 '22 at 21:24
0

So I bought a new M1 and migrated to it. I took it back and migrated back. I was receiving this error. Found that I needed to run sudo rm -Rf /opt/homebrew after re-installing brew to get things flowing again. 16G Ram on the M1 didn't replace my workflow with Intel using 64G.

JJ Smith
  • 11
  • 1