Skip to content
Latchkey

make "No rule to make target" in CI

make needs a file to satisfy a dependency but that file does not exist and no rule tells make how to create it. The prerequisite was deleted, is in the wrong path, or a header/generated file is missing.

What this error means

make stops with "make: *** No rule to make target 'foo.h', needed by 'main.o'. Stop." naming a prerequisite it cannot produce or locate.

make
make: *** No rule to make target 'include/config.h', needed by 'main.o'.  Stop.

Common causes

A prerequisite file does not exist

A header or source listed as a dependency was deleted, renamed, or never checked out on the runner.

A generated file was not generated first

A file expected to be produced by an earlier step is missing because that step did not run in CI.

How to fix it

Restore or regenerate the prerequisite

  1. Confirm the named file exists at the path make expects.
  2. Restore a deleted file or run the generator step that produces it.
  3. For generated headers, run the generation target before the main build.
Terminal
make generate-config
make

Fix the path in the Makefile

If the file moved, update its path or the VPATH so make can find the prerequisite.

Makefile
VPATH = include:src

How to prevent it

  • Check that all generated files are produced by an explicit target.
  • Keep prerequisite paths in the Makefile in sync with the tree.
  • Do clean builds so stale expectations do not persist.

Related guides

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