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

20

294

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

I run:

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.

Trust answered 23/11, 2020 at 6:13 Comment(1)
still same for OpenJDK 17Tanner
C
467

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>

Callable answered 25/11, 2020 at 0:57 Comment(15)
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?Basket
After this command : /usr/sbin/softwareupdate --install-rosetta --agree-to-license I get Installing Rosetta 2 on this system is not supported.Plasty
I am also facing the same issue is there any other workaround for this Installing Rosetta 2 on this system is not supported.Kettledrummer
Uncheck run with rosetta in terminal and it can be install Rosetta 2. It works for meRetro
i unchecked rosetta in terminal, but it still get that error @DucNguyenBebop
Quit terminal and then try again.Ayrshire
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?Omphale
Add an alias alias brew86="arch -x86_64 /usr/local/homebrew/bin/brew" to your .zshrc for future convenienceHinojosa
For those getting the response: "Permission denied @ rb_file_s_symlink", try: $ sudo chown -R $(whoami) $(brew --prefix)/*Palatal
hey, thanks for this btw. After adding your 3rd command to install my package, which in this case is rgdbs - rgbds.gbdev.io/install/macos - getting the following error: /usr/local/Cellar/libpng/1.6.37 is not a valid keg Any ideas?Allegorical
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 workedPathic
If you have a Brewfile to install -- I used arch -x86_64 /usr/local/homebrew/bin/brew bundle --file ~/Brewfile to install the packages that require Rosetta correctly.Immortality
Rosetta not enough for you? Try Rosetta2!Nob
Thanks! I had to use arch -x86_64 /usr/local/bin/brew install <package> because arch -x86_64 brew install <package> failed with "Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!".Demetri
/usr/sbin/softwareupdate --install-rosetta --agree-to-license didn't work for the first time, I had to reopen my terminal. And istalling package also encontered problem. I had to use arch -x86_64 /usr/local/bin/brew install <package>Reckon
C
151

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.

Coastal answered 21/12, 2020 at 18:52 Comment(8)
"You could rename the brew commands to something like brew86 and brewARM to help keep them separate" - How exactly to do this?Gallinacean
@Gallinacean 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 fileWilkens
I also used the alias. I wonder why this is not standard for the homebrew installation... ;)Cathar
How do you know if want to install something to 86 or ARM?Keyes
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.Sigler
@TyConway normally you would want to use ARM unless there's some special reason not to. ARM means you're using the native instruction set for the new Apple ARM chips (M1, M2, etc) instead of using the emulated legacy x86 instruction set. The native instruction set is faster than the emulated legacy instruction set.Palatial
Don't forget to run source ~/.zshrc after adding new aliases in order to make your terminal recognise them.Maidenhead
In my case I migrated an Intel-based MBP to an ARM-based MBP. The former had already installed homebrew and that version is the one that ended up accessible from the command line after migrating. I just had to reinstall homebrew in the new MBP executing the official command /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". This installed homebrew in /opt/homebrew and made it the default brew command. Anyhow, this answer and @NBTX's comment were both helpful.Aloeswood
L
127

Run this in the terminal it fixes the issue

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

Lyn answered 9/2, 2022 at 11:53 Comment(8)
After running this I was able to run brew install php with no problemsCalcine
+ adding that line to your shell (.zshrc on my case) prevents you from having to write that line every time you close and open the terminalMireillemireles
This fixed my issue after running a $ brew doctorTwelfth
This fixed my issue with the following error: 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: docs.brew.sh/Installation You can migrate your previously installed formula list with: brew bundle dumpArnie
After running this I was able to run brew install [email protected]Wainwright
the error Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)! will be fixed with this command.Kathlyn
What is actually this command do?Enamelware
Thank you Thank you Thank you @gandharv garg!!Marmoreal
T
68

Just use:

arch -arm64 brew install package-name

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

Thomey answered 21/7, 2021 at 5:25 Comment(6)
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.Parrnell
didn't work for me to upgrade nodeGalenic
it worked for me with M1 mac.Norseman
It worked for me to install poetryRobbierobbin
It didn't worked for me. :( I got this error Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!Hylton
Not work for me M2 mac.Efficient
A
60

There is a lot of helpful info in the replies here, but there doesn't seem to be a direct answer to the original request, "Need help with exact steps to follow."

In case it may help people facing this issue in the future, I'll share the exact steps that I followed to resolve the issue.

The following CLI commands are intended to be run on an Apple silicon-equipped Mac in the built-in Terminal application running the macOS-default shell, Zsh:

  1. Run a Homebrew command to confirm that an error like the following appears:

    $ brew install <formula>
    
    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
    

    Or:

    $ brew doctor
    
    Warning: Your Homebrew's prefix is not /opt/homebrew.
    Some of Homebrew's bottles (binary packages) can only be used with the default
    prefix (/opt/homebrew).
    You will encounter build failures with some formulae.
    

    If either of these errors appears, it is likely that the steps below are applicable to your case.

  2. Navigate to the /opt folder:

    $ cd /opt
    
  3. Create a folder named homebrew. By default superuser privileges are required to write inside of the /opt folder, which means that it is necessary to use sudo:

    $ sudo mkdir homebrew
    
  4. Grant write access to the homebrew folder so that your user can perform the Homebrew installation:

    $ sudo chmod go+w homebrew
    
  5. Perform the four steps listed on the "Alternative Installs" page (the page mentioned in the first error message in step 1):

    1. Install Homebrew:

      $ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
      
    2. Set Homebrew's prefix in your current Terminal session:

      $ eval "$(homebrew/bin/brew shellenv)"
      
    3. Update Homebrew:

      $ brew update --force --quiet
      
    4. Revoke write access to specific folders and files:

      $ chmod -R go-w "$(brew --prefix)/share/zsh"
      
  6. Set Homebrew's prefix in future Terminal sessions by adding the necessary command to one of Zsh's startup files. As far as I can tell, .zshrc is the preferred startup file for this type of command:

    $ echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
    

    Note that if there are any other existing Terminal sessions on your machine that have been open since before running the above command, the correct Homebrew prefix will still be unset in those sessions.

  7. Confirm that Homebrew's prefix is now properly set:

    $ type -a brew
    
    brew is /opt/homebrew/bin/brew
    brew is /usr/local/bin/brew
    

    Or:

    $ brew doctor
    
    Your system is ready to brew.
    

It should now be possible to continue using Homebrew normally.

Alto answered 30/6, 2022 at 19:5 Comment(6)
This really helped me, but I ran into some errors while following the listed steps. When running brew update --force --quiet, right after Initialized empty Git repository in /opt/homebrew/.git/, the next line was fatal: not in a git directory. This answer made me think that it's a permission issue, so I created the .git folder manually. After that it looked like it's working, but then it stopped with Error: update-report should not be called directly!. Nevertheless, after this, I was still able to use brew properly.Feasible
@KarsaiPéter, if you run brew doctor or brew config, are any problems reported? One idea is that Xcode Command Line Tools aren't installed. xcode-select -p to check if installed; xcode-select --install to install. Another idea is suggested here: Are you using an admin account? Or maybe it would help if your user were the owner of the /opt/homebrew folder? Perhaps try chown -R $USER /opt/homebrew (with sudo if needed) and then reinstall Homebrew.Alto
I also got fatal: not in a git directory /opt/homebrew/.git error message, even though brew doctor shows Your system is ready to brew. Manually adding that .git repo will cause brew doctor to throw : "Warning: Missing github.com/Homebrew/brew git origin remote." error message. I then rm -r /opt/homebrew/.git/ the warning went away from brew doctor. I believe this approach is to reuse the old .git repo (for Intel-based CPU installations) instead using the "default" Apple Silicon chip installation. As long as brew doctor works, no issues.Odine
This is the best answer! Well-explained, well formatted, in-depth answer! This answer should get more votes!Seagoing
This answer just saved me possibly hours of manual debugging. Thank you!Pycnidium
If you're getting fatal: not in a git directory /opt/homebrew/.git, it is because its expecting ure inside a git repo. Try the other method which is git clone https://github.com/Homebrew/brew homebrew as stated here docs.brew.sh/Installation#alternative-installsUnder
T
37

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

Trust answered 23/11, 2020 at 6:27 Comment(4)
This works and doesn't require brew to be installed twice.Carl
Wrong @dwaz. this just means all your brew commands by default will be for intelLaveralavergne
tks, this works, i remember to try run a macos project with flutter, make modifcations to wezterm to use neovim, pffWeapon
Before setting Open using Rosetta, set the iTerm's Profile Command to the x86_64 version of the shell to be used.Fleck
L
22

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

Lento answered 17/1, 2021 at 11:28 Comment(4)
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... ;)Cathar
my answer based on M1 chips and my experienceLento
Seconding @Martin's note above. Regardless of your experiences, it'd be good to make folks aware.Charin
M1 - worked perfectlyLubet
E
14

See: https://docs.brew.sh/Installation

1. Clone homebrew

$ cd /opt
$ sudo git clone https://github.com/Homebrew/brew homebrew

2. Chown dir

$ sudo chown -R $(whoami):staff /opt/homebrew

3. Update new brew shellenv temporarily, more shellenv meaning see man brew

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

4. New brew update

$ brew update --force --quiet
==> Homebrew has enabled anonymous aggregate formula and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).

==> Tapping homebrew/core
Cloning into '/opt/homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1265097, done.
remote: Counting objects: 100% (207/207), done.
remote: Compressing objects: 100% (97/97), done.
remote: Total 1265097 (delta 120), reused 192 (delta 110), pack-reused 1264890
Receiving objects: 100% (1265097/1265097), 517.64 MiB | 3.02 MiB/s, done.
Resolving deltas: 100% (872476/872476), done.
Tapped 3 commands and 6273 formulae (6,616 files, 566.4MB).

5. Make sure remove other person write privage

$ chmod -R go-w "$(brew --prefix)/share/zsh"

6. Confirm new brew version

$ brew --version
Homebrew 3.6.0
Homebrew/homebrew-core (git revision 57f5c02ec6a; last commit 2022-09-10)

7. Brew config show

/opt/homebrew on  stable (93ea8cb2c) 💰 17:17:54
$ brew config
HOMEBREW_VERSION: 3.6.0
ORIGIN: https://github.com/Homebrew/brew
HEAD: 93ea8cb2c40e1ef25f1489b0267526bd47bc8030
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 57f5c02ec6af877482ecd8753066d6a277cd3213
Core tap last commit: 72 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_REPOSITORY: /opt/homebrew
HOMEBREW_CELLAR: /opt/homebrew/Cellar
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 10-core 64-bit westmere
Clang: 13.1.6 build 1316
Git: 2.32.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.5.1-x86_64
CLT: 13.4.0.0.1.1651278267
Xcode: 13.4.1
Rosetta 2: true

8. Add new brew shellenv to strart bash shell, eg. ~/.zshrc~/.barshrc etc.

eval "$(/opt/homebrew/bin/brew shellenv)"
Eleni answered 10/9, 2022 at 9:34 Comment(1)
This is starting from a place where you do not have brew installed. The OP seems to have brew installed and expects it to work. What do you do if you already have the directory /opt/homebrew? How can you safely transition from the state I described to the end state the OP desires, brew installed and functional on M1 mac?Lempira
C
12

Probably this error is related running brew on M1/M2 Mac instead instead of Intel based Mac, atleast that was in my case. I had previously restored a Time Machine backup from Intel to M2.

According to the Homebrew documentation, the default installation script installs Homebrew to its preferred /usr/localfor macOS Intel and /opt/homebrew for Apple Silicon.

You can well use this, as it worked well for me-

  1. re-install brew by running this in your terminal /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. run brew bundle dump

You should be good on using brew

Chemesh answered 12/2, 2023 at 2:17 Comment(0)
R
11

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.

Remainder answered 22/3, 2022 at 18:39 Comment(3)
Thanks, this worked for me. Note that to uninstall Homebrew, see github.com/homebrew/install#uninstall-homebrew.Mingmingche
I installed with the new .pkg installer and running /opt/homebrew/bin/brew [username] gives an error. I just made this alias alias brewlicon="/opt/homebrew/bin/brew" that I can use whenever I need the silicon versionLeftward
and I added export PATH=$PATH:/opt/homebrew/bin. Adding it to the end is intentional. I default to the normal brew in /usr/local, but use brewlicon if I need toLeftward
Z
8
  • Background
    • brew location/version
      • default=X86=Intel: /usr/local
      • M1/M2=arm=Apple Silicon: /opt/homebrew
  • Has Done
    • Installed Rosetta
    • x86 brew
      • arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Solution
    • for arm=Apple Silicon package
      • arch -arm64 /opt/homebrew/bin/brew install package_name
    • for x86=Intel package
      • arch -x86_64 /usr/local/bin/brew install package_name
  • Optimization
    • add alias to startup script (eg ~/.zshrc)
      alias armbrew="arch -arm64 /opt/homebrew/bin/brew"
      alias x86brew="arch -x86_64 /usr/local/bin/brew"
      
      • then can use
      armbrew install package_name
      x86brew install package_name
      
Zurheide answered 25/7, 2023 at 7:18 Comment(0)
E
4

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
Extrados answered 1/2, 2022 at 22:29 Comment(2)
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.Galenic
An additional note to Dashiell's comment: make sure you run brew bundle dump with /usr/local/Homebrew/bin/brew or otherwise you'll be executing the newly installed brew, which won't have access to the old packages.Threadgill
E
4

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

Enmesh answered 11/3, 2022 at 22:26 Comment(1)
This happened to me trying to install homebrew from the VSCode terminal. Just use a Regular terminal.Ovalle
L
3

For M1 Mac's use following:

arch -arm64 /opt/homebrew/bin/brew install SOME_TOOL

Example:

arch -arm64 /opt/homebrew/bin/brew install gitguardian/tap/ggshield
Lustreware answered 18/7, 2023 at 15:53 Comment(0)
E
2

Go over to https://brew.sh and use the command. It will download and install brew again correctly.

Elvera answered 14/6, 2022 at 14:57 Comment(1)
Worked in an M2 mac computer with backup restored from an Intel MacDell
B
0

I had installed Homebrew using iTerm enabled for the Apple ARM chip (M1), but when using a different terminal program that was Intel-based (and thus opening in Rosetta) I got this error. The latter app is seen as Intel, and thus wants to use the older Homebrew path.

Buckles answered 21/6, 2022 at 14:41 Comment(0)
S
0

Run this command as this will resolve the issue

arch -arm64 brew install kotlin
Stonge answered 14/9, 2022 at 19:59 Comment(1)
arch: Unknown architecture: arm64Hime
A
0

Brew, Git, etc for intel processors vs. the m1 and m2 chips is in different locations, but with migrating from an old mac, Apple doesn't protect users from these issues, and leaves you to solve on your own. In fact, they seem to encourage migrating your incompatible tools.

In latest Macs with M2 processor, this process is most easily, and curiously least documented, accomplished this way:

  1. Uninstall with the uninteractive command:

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

    Copy the entire two lines above. Here is the link for it.

    For some reason that un-installs every version of brew, while the default uninstall command doesn't. To be safe, maybe uninstall with the first command of:

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

    Then uninstall with the noninteractive. in any event, if you type "brew" in your terminal after the uninstall, you should get an non recognized command, if you don't you have one of the brew's installed.

  2. Now that brew is gone, install:

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

    Found here.

  3. After doing that, brew will give you 2 more commands to install to ensure you can run brew from any directory. Don't skip that. The command is custom for your username.

Ascospore answered 7/8, 2023 at 18:3 Comment(0)
P
0

For the lazy among us, just set an alias in your .zshrc/.bashrc that remaps brew with the arch -arm64 prefix:

alias brew="arch -arm64 brew"

Elegant? No. Works? Yes.

Pother answered 9/10, 2023 at 1:58 Comment(0)
C
-1

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.

Comminate answered 24/1, 2022 at 14:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.