Zsh: bad CPU type in executable

apple-siliconm1terminalzsh

I am using the terminal on an Apple M1 MacBook. I try to use a cli tool that is not build for aarm64, so I get this error message in the terminal:

zsh: bad CPU type in executable

Is there anything I can do to use this cli tool e.g. with emulation or something? How can I run binaries on a M1 based Mac in the Terminal that is not natively built for Arm?

Best Answer

When macOS tries to run an app that is not built for Apple silicon, macOS will prompt to install Rosetta 2 to automatically translate the app to Apple silicon.

In Terminal, there is no automatic detection for missing Rosetta to run older architecture command line tools.

If you haven't been prompted for any other app already, manually install Rosetta 2:

softwareupdate --install-rosetta

If you need to run a universal binary in the previous architecture, use arch and specify the architecture. You need to manually specify the architecture for binaries that need to run other binaries that are not built for Apple silicon, like Homebrew.

arch -x86_64 …

e.g. arch -x86_64 brew install packagename

Alternatively, you can run the entire Terminal app using Rosetta by opening Get Info on Terminal.app in Finder and checking ‘Open using Rosetta’. This way will Terminal and every binary it tries to run through Rosetta, so Apple silicon binaries won't be supported and performance will be impacted, but you don't need to specify the architecture to run old binaries.