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

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.

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>

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.

Run this in the terminal it fixes the issue
eval "$(/opt/homebrew/bin/brew shellenv)"

Just use:
arch -arm64 brew install package-name
replace 'package-name' with the package you want to install.

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.

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:
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.
Navigate to the /opt folder:
$ cd /opt
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
Grant write access to the homebrew folder so that your user can perform the Homebrew installation:
$ sudo chmod go+w homebrew
Perform the four steps listed on the "Alternative Installs" page (the page mentioned in the first error message in step 1):
Install Homebrew:
$ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Set Homebrew's prefix in your current Terminal session:
$ eval "$(homebrew/bin/brew shellenv)"
Update Homebrew:
$ brew update --force --quiet
Revoke write access to specific folders and files:
$ chmod -R go-w "$(brew --prefix)/share/zsh"
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.
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.

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

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.

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)"

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

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

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

Run this command as this will resolve the issue
arch -arm64 brew install kotlin

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.

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-
re-install brew by running this in your terminal /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
run brew bundle dump
You should be good on using brew

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.

Related

Why I can't install brew on macOS?

I am trying to install brew on my co-worker's macOS. I have brew on my computer.
Not sure why we are having problems to install it on his computer. I am following this turial.
When I run:
% brew doctor
zsh: command not found: brew
It says brew was not installed.
I already edited his path at .zshrc. However, I did not put the comment suggested on the tutorial. Not sure if it makes any difference:
#Michaels-MacBook-Air ~ % cat .zshrc
export PATH=/usr/local/bin:$PATH
This is on:
#Michaels-MacBook-Air ~ % pwd
/Users/michaels
In addition, I already executed:
/bin/bash install.sh
Which return the following warning:
Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.
And I checked xcode-select is installed:
#Michaels-MacBook-Air ~ % xcode-select --version
xcode-select version 2396.
I am suspicious his PATH might be wrong:
#Michaels-MacBook-Air ~ % echo $PATH
/usr/local/bin:/usr/local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Keybase.app/Contents/SharedSupport/bin
Is this problematic?
If no, what else could be causing a problem?
From the Homebrew documentation:
This script installs Homebrew to its default, supported, best prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon and /home/linuxbrew/.linuxbrew for Linux)
If your coworker has an M1 or M2 mac, you'll need to add /opt/homebrew/bin to PATH.
To install brew, just run the following script:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Homebrew Official Documentation:
https://brew.sh/

Can't deploy heroku on Mac OS M1

I'm new on Heroku and trying to deploy my project here. After I typed this command in the terminal: curl https://cli-assets.heroku.com/install.sh | sh
and I also typed the administrative password correctly , I got this error message: unsupported arch: arm64
The script does not support arm64 (see line 40 pf the script).
The easier option is to install via brew
brew tap heroku/brew && brew install heroku
or download the tarball for macOS (if you still prefer doing it manually)
Download the tarball macOS
tar xvf heroku-darwin-x64.tar
sudo mv heroku /usr/local/lib
cd /usr/local/bin
ln -s /usr/local/lib/heroku/bin/heroku .
heroku --help
Apple Silicon Issues
If you’re getting the following error on a machine with an Apple M1 chip, you haven’t installed or declined to install Rosetta 2.
Bad CPU type in executable
Installing Rosetta 2 resolves this issue.
If you don’t want to install Rosetta 2 on your machine, you can install the Heroku npm package globally and use your own Node binary locally. Only v16 of Node has M1 ARM support and npm isn’t the recommended install method.
ref: heroku install
brew tap heroku/brew && brew install heroku
This command doesn't work for me
==> Installing heroku from heroku/brew
Error: Your Xcode (14.0.1) is too outdated.
Please update to Xcode 14.1 (or delete it).
Xcode can be updated from the App Store.
but there is no update in theApp Store.
Try
arch -arm64 brew install heroic
Try
arch -arm64 brew install heroku

Error when installing graphviz on Mac using Homebrew

I am using macOS 11.5.1 Big Sur and I tried to install Graphviz via
brew install graphviz
but I got an error:
Error: python#3.9: wrong number of arguments (given 1, expected 0)
The version of my Homebrew is
Homebrew 3.0.5
Homebrew/homebrew-core (git revision 7ff3c752de; last commit 2021-08-13)
Homebrew/homebrew-cask (git revision af069ca1b1; last commit 2021-08-13)
I have no idea about the reason. Any suggestions? Thank you.
I have fixed this issue, by the following commands.
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --switch /Applications/Xcode.app
Then rerun the brew install:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
It works on my Mac. Just share in case that anyone encounters the same issue.
I was unable to get it to work with homebrew. I read other threads recommending trying with Ports, which I did and failed also, since I got a little farther with Ports, I continue to look and finally found this...
Uninstall graphiz if you tried homebrew: brew uninstall graphviz
Install Ports https://www.macports.org/install.php
edit the Ports installation https://www.macports.org/install.php
Edit opt/etc/macports/sources.conf, comment out the rsync entry, and add a new entry as follows:
#rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default]
https://distfiles.macports.org/ports.tar.gz [default]
Run sync in debug mode and watch for the tarball being used instead of rsync:
sudo port -d sync
sudo port install graphviz

Error in running Homebrew on Mac OS X mavericks

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -e:70: warning: Insecure world writable dir /usr in PATH, mode 040777 It appears Homebrew is already installed. If your intent is to reinstall you should do the following before running this installer again: rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
I have this on my terminal but I cant make use of homebrew. I need to use homebrew to install django pyhton web framework. However I don't seem to get the error here. It says its already installed but none of the brew commands work.
ghochee-macbook-pro:logs streamoid$ brew doctor -bash: brew: command not found <<<<<
Can anyone please help? I also see that there is no .bash_profile file with the PATH variable set, am I looking the right folder and file here?
It sounds like /usr/local/bin isn't on your $PATH. You can add it by running the following command in the terminal:
echo 'export PATH="/usr/local/bin:${PATH}"' >> ~/.bash_profile
Then restart your terminal for the changes to take affect.

Homebrew freezes when running brew doctor or brew --config

A few days ago, homebrew started to stuck when I try to run brew doctor or brew --config. The output is:
$ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: 391ed374442cb8f91d9168ccd23f1c97b84686d1
Last commit: 6 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit sandybridge
OS X: 10.10.1-x86_64
and
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Setting DYLD_* vars can break dynamic linking.
Set variables:
DYLD_LIBRARY_PATH: /usr/local/kde4/lib:/Users/<username>/Desktop/anderes/benvium-libimobiledevice-macosx-8507dd2
The only way to exit is sending a SIGINT to the process. Anyway, brew update worked:
$ brew update
Updated Homebrew from cd9895d9 to 391ed374.
==> Updated Formulae
curl fwknop john-jumbo sshrc
$ brew update
Already up-to-date.
I tried reinstalling homebrew, but it does not seem to work:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
$ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/Users/<username>/.rbenv/shims/ruby: line 21: /usr/local/Cellar/rbenv/0.4.0/libexec/rbenv: No such file or directory
Surprisingly, the brew command itself does work even after the rm command above. I'm wondering what I'm doing wrong. Thanks for any help!
I got a solution now: xcode-select was pointing to the wrong directory. sudo xcode-select -switch /Applications/Xcode.app solved the problem.

Resources