Apple Silicon: port all Homebrew packages under /usr/local/opt/ to /opt/homebrew
Solution 1:
According to https://docs.brew.sh/Installation, /usr/local
is for Intel binaries, /opt/homebrew
for ARM. So you may want to reinstall instead of just migrating.
You can dump the list of currently installed packages with brew bundle dump
. To duplicate your current installation, you'll need to
-
run
brew bundle dump
to create aBrewfile
-
install ARM Homebrew into
/opt/homebrew
by following the instructions in https://docs.brew.sh/Installationcd /opt sudo mkdir -p homebrew sudo chown -R $(whoami) homebrew curl -L https://github.com/Homebrew/brew/tarball/master |\ tar xz --strip 1 -C homebrew
-
make sure that the ARM version is at the beginning of your PATH
PATH=/opt/homebrew/bin:$PATH
-
Reapply the brew file created in step one
hash -d brew brew bundle install --file /path/to/Brewfile
-
Optionally run
brew analytics off
to turn off the tracking/analytics gathering done be Homebrew
PS: Some formulae don't seem to work on ARM yet
PPS: /usr/local/Cellar
and any symlinks from /usr/local/bin
into it can be removed afterwards.
Solution 2:
Here's the approach I ultimately took.
First, I took note of my installed brew packages:
brew list
I just kept this as a text file so that I could refer to it later. I then uninstalled the old version of Homebrew and all its packages:
cd ~/Desktop
wget https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh
chmod +x ./uninstall.sh
sudo ./uninstall.sh --path=/usr/local
and removed the file once that was done:
rm uninstall.sh
I then installed Homebrew with M1 support:
cd /opt; sudo mkdir homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Added the following to my ~/.zshrc
file:
export PATH=/opt/homebrew/bin:$PATH
and sourced it with:
source ~/.zshrc
I then referred to the list from my first step and began installing the necessary packages one by one :) Most packages I was using seem to already have ARM support which is awesome!