Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 562
Prashanth Sams Avatar asked Nov 23 '20 06:11

Prashanth Sams


People also ask

Does Homebrew work on M1 Mac?

Now, on your new M1 Mac, you can install Homebrew with /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" . After the install is complete you'll see a message similar to the one below. Remember, Homebrew is now going to install packages in /op/homebrew/bin .


4 Answers

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>

like image 126
emonz Avatar answered Sep 20 '22 15:09

emonz


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.

like image 30
court3nay Avatar answered Sep 18 '22 15:09

court3nay


Just use:

arch -arm64 brew install package-name

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

like image 41
Jeff Hogg Avatar answered Sep 19 '22 15:09

Jeff Hogg


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

like image 43
Prashanth Sams Avatar answered Sep 21 '22 15:09

Prashanth Sams