[ISSUE] Local compile failing - Bad CPU type in executable on Apple Sillicon M4

I think this one is pretty straightforward. When hitting local compile I immediately get the following error on the terminal:

 *  Executing task: make -f '/Users/****/.particle/toolchains/buildscripts/1.16.0/Makefile' compile-all 

/bin/bash: /Users/****/.particle/toolchains/buildtools/1.1.1/make: Bad CPU type in executable

 *  The terminal process "/bin/bash '-c', 'make -f '/Users/****/.particle/toolchains/buildscripts/1.16.0/Makefile' compile-all'" failed to launch (exit code: 126). 
 *  Press any key to close the terminal. 

This most likely has something to do with the make binaries being compiled for Intel (x86_64), while I am running on a Mac with Apple Silicon (ARM64).

Has someone faced and solved this issue before?

Env audit:

{
    "username": null,
    "workspace": {
        "name": "******",
        "isWorkspace": false,
        "folders": [
            {
                "location": "/Users/****/Documents/code/*****",
                "hasValidPath": true,
                "settings": {
                    "firmwareName": "deviceOS",
                    "firmwareVersion": "6.2.1",
                    "targetDevice": "****",
                    "targetPlatform": "boron",
                    "debugWarningShown": false,
                    "compileButtonAction": "localAppDeviceOS",
                    "flashButtonAction": "localAppDeviceOS",
                    "disableWelcomeScreen": false,
                    "disableDeviceOSOutdatedCheck": false,
                    "disableLocalCompilerDirtyCheck": false,
                    "enableVerboseLocalCompilerLogging": true,
                    "compileDefines": [],
                    "customDeviceOSLocation": "",
                    "maxAllowedToolchains": 4,
                    "enablePre-releaseDeviceOSBuilds": false
                },
                "files": [
                    ".git",
                    ".git/COMMIT_EDITMSG",
                    ".git/FETCH_HEAD",
                    ".git/HEAD",
                    ".git/ORIG_HEAD",
                    ".git/config",
                    ".git/description",
                    ".git/hooks",
                    ".git/index",
                    ".git/info",
                    ".git/logs",
                    ".git/objects",
                    ".git/packed-refs",
                    ".git/refs",
                    ".gitignore",
                    ".vscode",
                    ".vscode/settings.json",
                    "README.md",
                    "boron_firmware_1742855412411.bin",
                    "boron_firmware_1742945721457.bin",
                    "lib",
                    "lib/MS5837",
                    "project.properties",
                    "src",
                    "src/*****.cpp"
                ]
            }
        ]
    },
    "cli": {
        "binpath": "/Users/****/bin/particle",
        "ok": true,
        "version": "3.34.0"
    },
    "localCompiler": {
        "ok": false,
        "dependencies": [
            {
                "id": "deviceOS@6.2.1",
                "ok": true
            },
            {
                "id": "gcc-arm@10.2.1",
                "ok": false
            },
            {
                "id": "buildtools@1.1.1",
                "ok": false
            },
            {
                "id": "buildscripts@1.16.0",
                "ok": true
            },
            {
                "id": "openocd@0.12.0-particle.2",
                "ok": false
            }
        ]
    },
    "platform": {
        "os": "darwin",
        "type": "Darwin",
        "release": "24.2.0",
        "arch": "x64",
        "path": {
            "key": "PATH",
            "value": "/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/****/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin",
            "entries": [
                "/Library/Frameworks/Python.framework/Versions/3.11/bin",
                "/opt/homebrew/bin",
                "/opt/homebrew/sbin",
                "/Users/****/bin",
                "/Library/Frameworks/Python.framework/Versions/3.12/bin",
                "/usr/local/bin",
                "/System/Cryptexes/App/usr/bin",
                "/usr/bin",
                "/bin",
                "/usr/sbin",
                "/sbin",
                "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin",
                "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin",
                "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin"
            ]
        },
        "homeDir": "/Users/****",
        "particleDir": "/Users/****/.particle",
        "particleToolchainDir": "/Users/****/.particle/toolchains"
    },
    "env": {
        "COMMAND_MODE": "unix2003",
        "HOME": "/Users/****",
        "HOMEBREW_CELLAR": "/opt/homebrew/Cellar",
        "HOMEBREW_PREFIX": "/opt/homebrew",
        "HOMEBREW_REPOSITORY": "/opt/homebrew",
        "INFOPATH": "/opt/homebrew/share/info:",
        "LOGNAME": "*****",
        "MallocNanoZone": "0",
        "OLDPWD": "/",
        "ORIGINAL_XDG_CURRENT_DESKTOP": "undefined",
        "PATH": "/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/****/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin",
        "PWD": "/",
        "SHELL": "/bin/zsh",
        "SHLVL": "0",
        "SSH_AUTH_SOCK": "/private/tmp/com.apple.launchd.gndkVUHQRI/Listeners",
        "TMPDIR": "/var/folders/rz/35p4mqvs7z32k2sh52_gyftm0000gn/T/",
        "USER": "****",
        "VSCODE_CODE_CACHE_PATH": "/Users/****/Library/Application Support/Code/CachedData/ddc367ed5c8936efe395cffeec279b04ffd7db78",
        "VSCODE_CRASH_REPORTER_PROCESS_TYPE": "extensionHost",
        "VSCODE_CWD": "/",
        "VSCODE_ESM_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess",
        "VSCODE_HANDLES_UNCAUGHT_ERRORS": "true",
        "VSCODE_IPC_HOOK": "/Users/****/Library/Application Support/Code/1.98-main.sock",
        "VSCODE_NLS_CONFIG": "{\"userLocale\":\"en-us\",\"osLocale\":\"en-us\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"/Applications/Visual Studio Code.app/Contents/Resources/app/out/nls.messages.json\",\"locale\":\"en-us\",\"availableLanguages\":{}}",
        "VSCODE_PID": "17940",
        "XPC_FLAGS": "0x0",
        "XPC_SERVICE_NAME": "application.com.microsoft.VSCode.1841399.1841405",
        "_": "/Applications/Visual Studio Code.app/Contents/MacOS/Electron",
        "__CFBundleIdentifier": "com.microsoft.VSCode",
        "__CF_USER_TEXT_ENCODING": "0x1F5:0x0:0x0",
        "ELECTRON_RUN_AS_NODE": "1",
        "VSCODE_L10N_BUNDLE_LOCATION": ""
    },
    "versions": {
        "node": "20.18.2",
        "acorn": "8.12.1",
        "ada": "2.9.0",
        "ares": "1.33.1",
        "base64": "0.5.2",
        "brotli": "1.0.9",
        "cjs_module_lexer": "1.4.1",
        "cldr": "44.1",
        "icu": "74.2",
        "llhttp": "8.1.2",
        "modules": "132",
        "napi": "9",
        "nghttp2": "1.61.0",
        "openssl": "0.0.0",
        "simdutf": "5.5.0",
        "tz": "2024b",
        "undici": "6.21.1",
        "unicode": "15.1",
        "uv": "1.46.0",
        "uvwasi": "0.0.21",
        "v8": "13.2.152.36-electron.0",
        "zlib": "1.3.0.1-motley",
        "electron": "34.2.0",
        "chrome": "132.0.6834.196",
        "microsoft-build": "11161602"
    },
    "vscode": {
        "appName": "Visual Studio Code",
        "appRoot": "/Applications/Visual Studio Code.app/Contents/Resources/app",
        "machineId": "27a0afa5cbc5cfa68bfb6876bbc7ba4193e97abdf5b1b7ad116721382193743a",
        "sessionId": "e8e75f69-26c0-495c-801d-87f8941a892e1742948969862",
        "version": "1.98.2"
    },
    "extensions": [
        {
            "id": "ms-vscode.js-debug",
            "version": "1.97.1"
        },
        {
            "id": "ms-vscode.js-debug-companion",
            "version": "1.1.3"
        },
        {
            "id": "ms-vscode.vscode-js-profile-table",
            "version": "1.0.10"
        },
        {
            "id": "marus25.cortex-debug",
            "version": "1.12.1"
        },
        {
            "id": "mcu-debug.debug-tracker-vscode",
            "version": "0.0.15"
        },
        {
            "id": "mcu-debug.memory-view",
            "version": "0.0.25"
        },
        {
            "id": "mcu-debug.peripheral-viewer",
            "version": "1.4.6"
        },
        {
            "id": "mcu-debug.rtos-views",
            "version": "0.0.7"
        },
        {
            "id": "ms-python.debugpy",
            "version": "2025.4.1"
        },
        {
            "id": "ms-python.python",
            "version": "2025.2.0"
        },
        {
            "id": "ms-python.vscode-pylance",
            "version": "2025.3.2"
        },
        {
            "id": "ms-toolsai.jupyter",
            "version": "2025.2.0"
        },
        {
            "id": "ms-toolsai.jupyter-keymap",
            "version": "1.1.2"
        },
        {
            "id": "ms-toolsai.jupyter-renderers",
            "version": "1.1.0"
        },
        {
            "id": "ms-toolsai.vscode-jupyter-cell-tags",
            "version": "0.1.9"
        },
        {
            "id": "ms-toolsai.vscode-jupyter-slideshow",
            "version": "0.1.6"
        },
        {
            "id": "ms-vscode.cpptools",
            "version": "1.23.6"
        },
        {
            "id": "particle.particle-vscode-core",
            "version": "1.16.36"
        },
        {
            "id": "particle.particle-vscode-pack",
            "version": "1.16.36"
        },
        {
            "id": "particle.particle-vscode-snippets",
            "version": "1.16.36"
        },
        {
            "id": "particle.particle-vscode-theme",
            "version": "1.16.36"
        }
    ]
}

Under normal circumstances it will work on a fresh install, but if you imported settings from an Intel-based Mac into your Apple silicon Mac, sometimes you can get into this situation.

See troubleshooting the CLI on Apple Silicon.

Another option is to install Rosetta.

1 Like

Tl;dr: Particle CLI tools work well on Apple Sillicon mac, but something about the VS Code Workbench extension is broken and fails to do local compiles of any kind.


PARTIAL SOLUTION:

I had used Particle Workbench for Visual Studio Code on a Windows environment before and thought that possibly the syncing of my VS settings into my new Mac might have corrupted something.

This is what I did:

  1. Turn off VS Code sync.
  2. Delete VS Code app from Mac.
  3. Delete all VS Code other files to get a fresh install:
rm -fr ~/Library/Preferences/com.microsoft.VSCode.helper.plist 
rm -fr ~/Library/Preferences/com.microsoft.VSCode.plist 
rm -fr ~/Library/Caches/com.microsoft.VSCode
rm -fr ~/Library/Caches/com.microsoft.VSCode.ShipIt/
rm -fr ~/Library/Application\ Support/Code/
rm -fr ~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
rm -fr ~/.vscode/
  1. Delete everything Particle in my mac
rm -fr ~/.particle/
rm -fr ~/{your_username}/bin/particle
rm -fr ~/{your_username}/Particle
  1. Install Particle CLI through terminal
    bash <( curl -sL https://particle.io/install-cli )

Partial success: run Particle's CLI particle flash --local from a terminal in my project's directory. I was able to flash a device via USB. Note that here I hadn't yet installed the Particle Workbench extension on VS Code.

PROBLEMS AGAIN:

  1. Install VS code again
  2. Install Particle Workbench on VS Code
  3. Configure for Boron device with deviceOS@6.2.1 toolchain
  • Try Particle: Compile application (local). I again get that same original error on the opened Bash.
  • Try 'Particle: Compile application (local)'. I again get that same original error n the opened Bash
Executing task: make -f '/Users/vmgm/.particle/toolchains/buildscripts/1.16.0/Makefile' flash-user 

/bin/bash: /Users/vmgm/.particle/toolchains/buildtools/1.1.1/make: Bad CPU type in executable

Running particle flash --local from the terminal still works but I think that is because it is doing a Cloud compile and then flashing through USB.


That's weird. It looks like the VSCode app is running x86 instead of Apple Silicon, but you just reinstalled it so that should not happen.

Found this line at the very bottom of the hidden section of troubleshooting the CLI on Apple Silicon rickkas7shared eariler:

Note that local compiles will still require Rosetta because the gcc-arm compilers and other tools are only installed as Intel binaries. If you are prompted to install Rosetta you should do so to use local compile.

Should probably be moved to very top. It looks like Workbench's local compile just doesn't work out of the box with Apple Sillicon ARM64. On Mac Silliscon you need to use Rossetta.

install Rosetta.

Thanks @rickkas7 for the help.