Fixing 'zsh: bad CPU type in executable' on Apple Silicon Macs

beginner🍎 macOS2026-06-05| macOS (Apple Silicon M1/M2/M3), Terminal (zsh/bash)

Error Message

zsh: bad CPU type in executable: ./filename
#apple-silicon#rosetta2#macos#terminal#zsh

The Problem

You’ve just set up a new Apple Silicon Mac, migrated your files, and opened the Terminal to get to work. But when you try to run a familiar CLI tool or a local script, everything grinds to a halt. Instead of the help menu or program output, you see a blunt error message:

zsh: bad CPU type in executable: ./filename

This happens because your Mac is trying to run a program written in a language it doesn't natively speak. While M1, M2, and M3 chips use the ARM64 architecture, many older tools—like legacy versions of Hugo, Terraform, or custom Go binaries—were compiled for Intel's x86_64 architecture.

Identifying the Root Cause

Apple Silicon processors handle instructions differently than Intel chips. Without a translator, your Mac looks at an Intel-based binary and sees gibberish. This error is the kernel's way of saying it doesn't recognize the instruction set of the file you're trying to execute.

Step 1: Inspect the Binary

Verify the architecture of the problematic file using the file command. It’s a built-in utility that reveals exactly what a file is. Run this in your terminal:

file ./filename

If the output contains Mach-O 64-bit executable x86_64, you’ve found the problem. Your Mac is trying to run an Intel-only file without the necessary translation layer.

Solution 1: Install Rosetta 2 (The Quick Fix)

Apple provides a translation layer called Rosetta 2. It sits between the software and the hardware, translating Intel instructions into ARM instructions on the fly. It’s remarkably efficient, often running apps at 70-80% of their native speed.

To install it, run this command in your Terminal:

softwareupdate --install-rosetta --agree-to-license

The download is small (about 400MB) and takes less than a minute. Once finished, try running your command again. It should work immediately without any further configuration.

Solution 2: Switch to Native ARM64 Binaries

Rosetta is a great bridge, but native software is always faster and easier on your battery. Most modern dev tools now offer dedicated Apple Silicon versions. Transitioning to native binaries is the best long-term strategy.

  • Check the source: Visit the project's GitHub "Releases" page. Look for downloads containing arm64, aarch64, or Apple Silicon in the filename.
  • Update Homebrew: If you migrated from an Intel Mac, your Homebrew installation might be in the wrong place. Native Homebrew lives in /opt/homebrew, while the Intel version lives in /usr/local.
  • Reinstall tools: Use brew list to identify old packages and reinstall them to ensure you're getting the ARM versions.

Solution 3: Recompile from Source

If you're dealing with a custom script or an internal tool, you can simply recompile it on your new machine. Since your environment is natively ARM64, standard compilers like clang, gcc, or the Go compiler will target your current architecture by default.

# Example: Recompiling a C++ tool
g++ -o my_tool main.cpp

# Confirm the new architecture
file my_tool

The output should now proudly state Mach-O 64-bit executable arm64.

Solution 4: Clean Up Your PATH

Sometimes the error persists because your shell is still looking at old Intel binaries hidden in /usr/local/bin. You need to tell your Mac to prioritize the new ARM versions. Open your configuration file:

nano ~/.zshrc

Add or move the Homebrew path to the front of your $PATH variable:

export PATH="/opt/homebrew/bin:$PATH"

Save the file (Ctrl+O, Enter) and exit (Ctrl+X). Refresh your session by running source ~/.zshrc.

Verifying the Fix

To see your fix in action, open Activity Monitor and navigate to the CPU tab. Look for the Kind column. Programs running natively will be labeled as "Apple," while those using Rosetta will be labeled as "Intel." If your CLI tool is native, it will show up as Apple (ARM) during execution.

Key Takeaways

  • Check before installing: Native ARM64 software is significantly more energy-efficient than translated Intel software.
  • Rosetta is optional: macOS doesn't include Rosetta 2 by default; you only need it if you rely on legacy tools.
  • Path hygiene: Moving to Apple Silicon is a great time to audit your .zshrc and remove hardcoded paths to old Intel directories.

Related Error Notes