Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All guides
AI for Automation By James Joyner IV · · 8 min read Last reviewed Jul 2026

Make Error: 'No rule to make target' — Cause, Fix, and Troubleshooting Guide

Quick answer

Fix make *** No rule to make target 'build'. Stop. — diagnose target typos, missing prerequisite files, wrong directory, and unbuilt generated files.

  • #automation
  • #troubleshooting
  • #make
Free toolkit

Fixing errors like this? Get 500 free DevOps AI prompts

500 copy-paste AI prompts for the stack you actually run — one PDF, free.

Overview

No rule to make target means make was asked to build something it has no instructions for and cannot find as an existing file. Make works backward from a goal: to build a target it needs either a rule whose target matches, or an existing file of that name. When neither exists, it stops.

Two shapes of the message appear. The first is when you ask for a target directly:

$ make build
make: *** No rule to make target 'build'.  Stop.

The second is when a target you do have a rule for depends on a prerequisite make cannot produce or find:

$ make deploy
make: *** No rule to make target 'dist/app.js', needed by 'deploy'.  Stop.

In both cases make is not failing to run a command — it never got that far. It could not construct a plan, because a name in the graph has no rule and no matching file on disk.

Symptoms

  • make: *** No rule to make target 'X'. Stop. when you invoke make X.
  • No rule to make target 'X', needed by 'Y'. Stop. — a prerequisite is unresolvable.
  • The target name you typed is not one of the Makefile’s rules.
  • The Makefile is correct but you are in the wrong directory, or a generated file has not been produced yet.
  • make (no args) works, but make sometarget fails.

Common Root Causes

1. Target name typo or wrong name

The target you asked for is not defined. Make’s targets are exactly the names before the colon in rule lines.

# List the actual targets defined in the Makefile
grep -E '^[a-zA-Z0-9_.-]+:' Makefile | cut -d: -f1 | sort -u
all
clean
image
package
test

There is no build here — the target is called package. make build fails; make package works.

2. Missing prerequisite file

A rule depends on a file that does not exist and has no rule to create it. Common with hand-listed source files that were renamed or deleted.

make: *** No rule to make target 'src/old_name.c', needed by 'app'.  Stop.
ls -l src/old_name.c
ls: cannot access 'src/old_name.c': No such file or directory

3. Running from the wrong directory

Make reads ./Makefile by default. Invoked from a parent or sibling directory, it either finds no Makefile or a different one whose targets differ.

pwd; ls Makefile
/opt/project/scripts
ls: cannot access 'Makefile': No such file or directory

4. Generated file not built yet, and no rule to build it

A target depends on an artifact that another step normally produces (a codegen output, a compiled bundle), but there is no rule wiring that dependency, so make cannot create it on demand.

5. VPATH / directory assumptions

The prerequisite exists but in a directory make is not searching. Without a correct VPATH or explicit path, make looks only in the current directory and reports no rule.

6. Missing .PHONY causing a name collision

A phony target that happens to share a name with a real directory/file can behave unexpectedly, but the inverse — a target you expect to be phony that make treats as a file — leads to “no rule” when the file is absent.

How to Diagnose

Step 1 — List the real targets and compare to what you typed.

grep -E '^[a-zA-Z0-9_.-]+:' Makefile | cut -d: -f1 | sort -u

If your target is not in the list, it is a name problem — you want a different target.

Step 2 — Confirm you are in the right directory with the right Makefile.

pwd
ls -l Makefile GNUmakefile makefile 2>/dev/null

Make prefers GNUmakefile, then makefile, then Makefile. Ensure the one you think you are running is the one present.

Step 3 — Dry-run to see the plan without executing.

make -n deploy
make: *** No rule to make target 'dist/app.js', needed by 'deploy'.  Stop.

-n shows exactly where the dependency graph breaks before any command runs.

Step 4 — Dump make’s database to inspect rules and variables.

make -p -n 2>/dev/null | grep -A2 'app.js'
dist/app.js: src/app.ts
#  Implicit rule search has not been done.

This reveals which rule references the missing prerequisite and what make thinks should build it.

Step 5 — Check the prerequisite file actually exists where make expects.

ls -l dist/app.js src/old_name.c 2>&1

Fixes

Use the correct target name. After listing targets, invoke the real one:

make package     # not: make build

Restore or fix the missing prerequisite. If a source file was renamed, update the Makefile to the new name:

# before
app: src/old_name.c src/main.c
# after
app: src/new_name.c src/main.c

Run make from the directory containing the Makefile, or point at it explicitly.

make -C /opt/project package     # run in that dir
make -f /opt/project/Makefile package

Add the missing rule so make can generate the artifact on demand. Wire the codegen/compile step into the graph:

dist/app.js: src/app.ts
	npx tsc --outDir dist src/app.ts

Set VPATH so make finds prerequisites in other directories.

VPATH = src:generated
app: main.c helper.c   # found via VPATH

Mark command-only targets .PHONY so make never treats them as files to look for:

.PHONY: build test clean deploy
build:
	./scripts/build.sh

What to Watch Out For

  • Make chooses its Makefile by name precedence (GNUmakefile > makefile > Makefile). A stray makefile can shadow the Makefile you meant to run.
  • No rule to make target 'X', needed by 'Y' points at the prerequisite X, not the target Y you asked for — fix X.
  • Always .PHONY your action targets (build, test, clean). Without it, a file or directory of the same name makes the target “up to date” and it silently does nothing.
  • make -n (dry run) is the fastest way to see where the graph breaks without side effects — reach for it before editing anything.
  • Tab-completion and copy-paste often introduce trailing spaces or wrong casing in target names; make is case-sensitive and exact.
Free download · 368-page PDF

Fixed it? Get 500 Automation & DevOps AI prompts — free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.

Did this fix your issue?

Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.