Skip to content
Latchkey

Make "No rule to make target" in CI

Make was asked to build a file it has no recipe for and that does not exist on disk. A prerequisite - a source, header, or generated file - is missing or its path is wrong.

What this error means

The build stops with "No rule to make target X, needed by Y". Make found a dependency on X but neither a rule to build it nor an existing X file, so it cannot proceed.

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

Common causes

A prerequisite file is missing or mispathed

A header or source listed as a dependency does not exist at the path the Makefile expects - often a generated file, a renamed file, or one excluded by a partial checkout.

A generated file was never produced

The target depends on a file that an earlier codegen/configure step should have created (e.g. config.h from ./configure). If that step was skipped, the prerequisite is absent.

How to fix it

Run the step that generates the prerequisite

If the missing file is generated, run the generator/configure step before make.

Terminal
./configure        # produces config.h, Makefile fragments, etc.
make

Fix the path or check out the missing file

  1. Confirm the prerequisite exists: ls src/config.h.
  2. If it is tracked, ensure a full checkout (and submodules) brought it in.
  3. If the path is wrong in the Makefile, correct the dependency or the variable that builds it.

How to prevent it

  • Run configure/codegen before make in CI, in that order.
  • Use a full checkout with submodules so all sources are present.
  • Keep generated-file paths in sync with the Makefile when files move.

Frequently asked questions

What causes ""No rule to make target""?
A header or source listed as a dependency does not exist at the path the Makefile expects - often a generated file, a renamed file, or one excluded by a partial checkout.
How do I fix "No rule to make target"?
If the missing file is generated, run the generator/configure step before make.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card