Apple Silicon: PlatformIO fails with "Unknown system error -86" due to prebuilt Ninja
On macOS (Apple Silicon M4), building ESP32 projects fails when PlatformIO tries to run its prebuilt tool-ninja package. The error is:
CMake Error at .../project.cmake:381 (__project):
Running
'/Users/username/.platformio/packages/tool-ninja/ninja' '--version'
failed with:
Unknown system error -86
This happens even after:
- Installing PlatformIO via Homebrew
- Installing system-native Ninja and CMake
- Removing
~/.platformio/packages/tool-ninjaand other caches
Steps to Reproduce:
- On macOS, install VSCode.
- Install PlatformIO via Homebrew:
brew install platformio. - Create a new ESP32 project using ESP-IDF + Arduino framework.
- Attempt to build:
platformio run --environment esp32dev -v.
Expected behavior:
- PlatformIO should use system-native Ninja or properly install an Apple Silicon-compatible Ninja.
- The project should build without
error -86.
Actual behavior:
- PlatformIO downloads its prebuilt
tool-ninja(x86_64) and fails to execute on Apple Silicon, givingUnknown system error -86.
System info:
macOS Version: 26.0.1 (Build 25A362) Architecture: arm64 (Apple Silicon) PlatformIO Core: 6.1.18 VSCode: 1.105.1 (Universal)
Note: Following the esp-idf instructions for install have helped and I can now compile normally, it would be nice to have this done automatically though, or at least stated in the install instructions from platformio.
From espressif (https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/linux-macos-setup.html#for-macos-users)
Install CMake & Ninja build:
> brew install cmake ninja dfu-util
install ccache for faster builds.
> brew install ccache
Not sure if it changed anything but I have also installed the arm exclusive version of vscode instead of universal.