Epidemiology & Technology

Migrate Homebrew on Mac from Intel to ARM for M1/M2

I had recently switched from an intel based Mac to a M2 based system. As usual, I migrated all my files when I set up the new M2 Mac. However, in the process, many of the old homebrew programs that had been installed using intel processor codebase also been migrated over as it is. So now am left with an x86 homebrew on an ARM64 architecture

The steps to remedy the situation come Courtsey Gromit at GitHub

Dump your current installed formulae list to ~/.Brewfile.

cd ~
arch -x86_64 /usr/local/bin/brew bundle dump --global
cat ~/.BrewfileCode language: PHP (php)

Reinstall Homebrew under the correct prefix (/opt/homebrew). Be sure to do the stuff listed at the end of the installation process under Next Steps; too many folks forget this and complain about “Homebrew not working” for them

Replicate your original formulae installation under “new Homebrew”. Note that core repos have changed a LOT over the last two years, so some formulae have disappeared or been renamed. Expect errors, and spending some time searching Homebrew for replacements for deprecated, disabled, and just plain missing formulae. Once you’re sure you’ve gotten your new setup as “whole” as it gets, you can then uninstall the old one:

/opt/homebrew/bin/brew bundle install --global Code language: PHP (php)

Download the uninstaller script and remove intel version and Run it

curl -fsSL -o /tmp/uninstall.sh https://raw.githubusercontent.com/Homeb
rew/install/HEAD/uninstall.sh. 

bash /tmp/uninstall.sh --path=/usr/localCode language: JavaScript (javascript)

In case facing problems with import of ZSH profile

nano ~/.zshrc

# ADD TO TOP
HOMEBREW_PREFIX=$(brew --prefix)
export FPATH="${HOMEBREW_PREFIX}/share/zsh/site-functions:${FPATH}"

# SAVE and exit

cd ~
rm -r .zcompdump*Code language: PHP (php)

Related Posts