# Checking dune files for semantic errors

**URL:** <https://discuss.ocaml.org/t/checking-dune-files-for-semantic-errors/18572>\
**Category:** Ecosystem\
**Tags:** dune\
**Created:** [September 30, 2026, 10:09pm UTC](https://discuss.ocaml.org/t/checking-dune-files-for-semantic-errors/18572 "2026-09-30T22:09:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaro](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@amaro](https://discuss.ocaml.org/u/amaro)\
**Post date:** [September 30, 2026, 10:09pm UTC](https://discuss.ocaml.org/t/checking-dune-files-for-semantic-errors/18572/1 "2026-09-30T22:09:34Z")

</div>

Recently I’ve found two kinds of errors in one of our `dune` files:

- A `dirs` stanza containing directories that do not exist, e.g. `(dirs foo bar)` when only `foo` exists.
- A `dune` file inside a directory absent from a `dirs` stanza in the parent, which meant it was ignored.

In both cases Dune did not report anything.

To catch such kinds of silly mistakes, it would be useful to have tools that might detect these and similar ones. Not necessarily by default, but maybe in a “strict” mode.

Is there already something that does that?

Note that the second case is debatable, since a `dirs` stanza means “just ignore everything in non-listed directories”. But, in practice, copy-paste errors, renamings and partial updates do happen. Having more sanity checks is always useful.
