Homebrew / install

📥 Homebrew (un)installer
https://brew.sh
BSD 2-Clause "Simplified" License
2.18k stars 1.02k forks source link

Install script doesn't detect arm64 for M3 Pro MacBook Pro #835

Closed willfaught closed 8 months ago

willfaught commented 8 months ago

What you were trying to do (and why)

Install Homebrew on my new M3 Pro MacBook Pro after using Migration Assistant to migrate from my Intel Mac.

What happened (include command output)

On the M3 Mac, using Terminal.app, I uninstalled Homebrew:

bash-3.2$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Warning: This script will remove:
/Users/Will/Library/Caches/Homebrew/
/Users/Will/Library/Logs/Homebrew/
/usr/local/Caskroom/
/usr/local/Cellar/
/usr/local/bin/brew -> /usr/local/bin/brew
Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] y
==> Removing Homebrew installation...
Warning: Failed to delete /usr/local/Caskroom
rm: /usr/local/Caskroom: Permission denied
Warning: Failed to delete /usr/local/Cellar
rm: /usr/local/Cellar: Permission denied
==> Removing empty directories...
Password:
==> /usr/bin/sudo /usr/bin/find /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var /usr/local/Caskroom /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks -name .DS_Store -delete
==> /usr/bin/sudo /usr/bin/find /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var /usr/local/Caskroom /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks -depth -type d -empty -exec rmdir {} ;
==> Homebrew uninstalled!
The following possible Homebrew files were not deleted:
/usr/local/.com.apple.installer.keep
/usr/local/Frameworks/
/usr/local/Homebrew/
/usr/local/bin/
/usr/local/etc/
/usr/local/include/
/usr/local/juniper/
/usr/local/lib/
/usr/local/opt/
/usr/local/remotedesktop/
/usr/local/sbin/
/usr/local/share/
/usr/local/texlive/
/usr/local/var/
You may wish to remove them yourself.

I installed Homebrew:

bash-3.2$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/bin
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/share
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Frameworks

Press RETURN/ENTER to continue or any other key to abort:

My brew config:

$ brew config
HOMEBREW_VERSION: 4.2.6
ORIGIN: https://github.com/Homebrew/brew
HEAD: cfac516ee045d869be34598152e80a11ef2befe7
Last commit: 6 days ago
Core tap JSON: 03 Feb 06:34 UTC
Core cask tap JSON: 03 Feb 06:42 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 3.1.4 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: dodeca-core 64-bit westmere
Clang: 15.0.0 build 1500
Git: 2.43.0 => /usr/local/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.3-x86_64
CLT: 15.1.0.0.1.1700200546
Xcode: 15.2
Rosetta 2: true

My brew doctor:

$ brew doctor
Your system is ready to brew.

My brew prefix:

$ brew --prefix
/usr/local

What you expected to happen

I expected it to install to /opt/homebrew. Instead, it installed to /usr/local.

It looks like this happens because Homebrew's install.sh looks at the output of /usr/bin/uname -m, which on my M3 Pro Mac is x86_64 instead of arm64 for some reason.

/usr/bin/uname -a is Darwin tmps-MacBook-Pro.local 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:59 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6030 x86_64.

which bash is /bin/bash.

$ file (which bash)
/bin/bash: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/bin/bash (for architecture x86_64):    Mach-O 64-bit executable x86_64
/bin/bash (for architecture arm64e):    Mach-O 64-bit executable arm64e

Open using Rosetta is disabled in the info for Terminal.app.

Step-by-step reproduction instructions (by running brew commands)

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

Figured out the issue. Needed to change my shell to /bin/bash, restart Terminal, uninstall, then install.

SMillerDev commented 8 months ago

That shouldn't be needed, but if uname is wrong you're probably running under Rosetta and that will detect as x86

willfaught commented 8 months ago

Yes, I think the issue was that my default shell was fish, installed via Homebrew, which was amd64, so everything installed/built with that was also amd64. By resetting to /bin/bash, I got an arm64 shell, which I could use to install an arm64 Homebrew, and then an arm64 fish shell.