Skip to content
Latchkey

Arduino CLI library "not found" / missing include in CI

The sketch includes a library header, but arduino-cli has no matching library installed, so the compiler cannot find the include. Libraries are installed separately from cores and are absent on a clean runner.

What this error means

An arduino-cli compile step fails with a fatal error that an included header was not found, for example "ArduinoJson.h: No such file or directory".

arduino-cli
sketch/blink.ino:1:10: fatal error: ArduinoJson.h: No such file or directory
 #include <ArduinoJson.h>
          ^~~~~~~~~~~~~~~
compilation terminated.

Common causes

The library was never installed

A clean runner has no libraries. Without arduino-cli lib install, the header the sketch includes is not on the include path.

The library name does not match the registry

A misspelled library name, or a name that differs from the registry entry, installs nothing and leaves the include unresolved.

How to fix it

Install the library before compiling

  1. Find the exact registry name with arduino-cli lib search <name>.
  2. Install it with arduino-cli lib install "<name>".
  3. Re-run the compile so the include resolves.
Terminal
arduino-cli lib search ArduinoJson
arduino-cli lib install "ArduinoJson"

Compile with an explicit library path

For a vendored or unpublished library, point the compile at its directory so the header is found.

Terminal
arduino-cli compile --fqbn esp32:esp32:esp32 --library ./libs/MyLib sketch/

How to prevent it

  • Install required libraries as an explicit CI step.
  • Pin library versions with lib install "Name@x.y.z".
  • Cache ~/.arduino15 so installed libraries persist.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →