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.
To switch an existing zsh terminal to x86_64 use this command:
arch -x86_64 zsh
binfmtin Linux? – Dmitry Grigoryev Dec 09 '20 at 10:22binfmtneeds handlers for the different formats. Installing Rosetta will add the functionality required to run Intel code on M1. – nohillside Dec 09 '20 at 23:22binfmtmakes sure the check happens right in theexeccall, so it doesn't matter if you start a foreign-architecture program from the GUI, the terminal, a script, or another binary. – Dmitry Grigoryev Dec 10 '20 at 11:56archcommand can be used to override that (as can the checkbox in Finder). – nohillside Dec 10 '20 at 12:42arch -x86_64 zsh(I have installed rosetta) – Samet Baskıcı Jan 07 '23 at 21:22arch -x86_64 zshon two computers but not witharch -x86_64 asdf install nodejs 14.17.4- that ran fine. – erikdstock Jan 11 '23 at 05:07arch -x86_64 /bin/zsh– amiabl Feb 21 '23 at 14:45