Newer MACs use an Arm chip whereas older ones use Intel. This means a new install dir for Homebrew which can really mess up your setup, especially if you used timemachine to migrate to your new machine.
To fix this mess we have to uninstall Brew from old location and install into the new location.
Note: I take no responsibility for the following steps. Be sure to check your own configuration and backup everything before following the steps below.
Backup your Brew configuration
First dump your Brew config:
brew bundle dump
Put the resulting file somewhere safe.
Uninstall Brew from old location
Download the Brew uninstall script from:
https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
You can then remove the “old” brew install at /usr/local
.
./uninstall.sh --dry-run path=/usr/local
Note: this command runs in “dry run” mode – check output is good first before removing the --dry-run
flag and running again:
./uninstall.sh path=/usr/local
Brew should now be uninstalled from the old location.
Install Brew to new location
Now reinstall brew to the new location. This time it should install to:
/opt/homebrew
Reinstall config
Now cd
to the directory containing your Brewfile
and run brew bundle
in the same directory.
Brew will then reinstall your old setup.