homebrew

Bad CPU type in executable after migrating to new Macbook


I just got a new Macbook and did the migration from my old one. It looks like the homebrew executables have a bad CPU type and don't work. Things are a bit stuck right now and I'm not sure how to move forward.

Even my ls is mapped to lsd and I can't list files.

Do I have to manually uninstall brew and related executables by deletion and start over?

enter image description here


Solution

  • DISCLAIMER: I didn't test this myself.

    If you don't want to alwasy use Rosetta2, you have to manually remove the Intel version of Homebrew, then install the M1 version.

    You can save the list of your Intel installed package with:

    brew list > myHomebrewPackages.txt
    

    You will then have to reinstall them on the M1 version.

    To remove the Intel version, download the uninstall script from the official Homebrew github repository. Make it executable with:

    chmod +x uninstall.sh
    

    and run it with:

    ./uninstall.sh --path=/usr/local
    

    Then install the M1 version with:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    

    The M1 version of Homebrew will be installed under /opt/homebrew.