dune "Error: I don't know how to build X" in CI
dune could not map the target on the command line to any file or alias it knows. Often the path is wrong, prefixed incorrectly, or names a build artifact that no stanza produces.
What this error means
dune build fails with "Error: I don't know how to build X", usually when a CI script passes an explicit target path that does not exist.
dune
Error: I don't know how to build bin/app.exe
Hint: did you mean bin/main.exe?Common causes
A wrong or misspelled target path
The explicit target the CI step passes does not match the executable name in the dune stanza.
Referencing a target from the wrong directory
The path is relative to a directory dune does not expect, so it resolves to nothing buildable.
How to fix it
Use the correct target name
- Check the
(name ...)in the relevant dune stanza. - Pass the matching
.exetarget or a build alias instead. - Prefer aliases over explicit paths in CI scripts.
Terminal
dune build bin/main.exe
# or just build everything:
dune build @allBuild an alias instead of a path
Aliases like @all or @runtest avoid brittle explicit paths.
Terminal
dune build @all @runtestHow to prevent it
- Match target paths to the
(name ...)in dune stanzas. - Prefer aliases (@all, @runtest) over explicit target paths in CI.
- Run the same dune command locally before wiring it into CI.
Related guides
dune "Error: No rule to build X" in CIFix dune "Error: No rule to build X" in CI - dune has no way to produce the requested target because the file…
dune "build @runtest ... FAILED" in CIFix "dune build @runtest" failures in CI - an inline or cram test diff, or a Fatal error exception, made a te…
dune "Error: Program X not found" (missing tool) in CIFix dune "Error: Program X not found in the tree or in PATH" in CI - a rule invokes a tool (menhir, ocamllex,…