[dune] The package XXX does not have any user defined stanzas attached to it

I just got the following error from dune when trying to build my project (named XXX):

$ dune build
Error: The package XXX does not have any user defined stanzas attached to
it. If this is intentional, add (allow_empty) to the package definition in
the dune-project file
-> required by _build/default/XXX.install
-> required by alias all
-> required by alias default

An internet search gives a single match, which has a link to Document `(allow_empty)` · Issue #5567 · ocaml/dune · GitHub but there is no answer there.

I have created the project XXX using $ dune init proj XXX as indicated in Quickstart — dune documentation, and my dune files in bin and lib are respectively

(executable
 (name XXX)
 (libraries XXX_lib))

and

(library
 (name XXX_lib))

Also, the bin directory has a file XXX.ml. Isn’t this the most standard that a project could be ? Or am I missing something ?

Edit: thanks to @nojb, I looked a bit more at my setup. I did only minimal changes compared to what dune init proj XXX preinstalls, and in particular, dune-project is the initial one (with dummy fields filled in). It turns out that the error was caused by removing (public_name xxx) from bin/dune and goes away if I add it back. I do not fully understand why: it would seem that the field public_name is useful only if public_name differs from name (see Stanza Reference — dune documentation) and that if I add it, then I should also add the field package to executable, but it turns out not to be necessary.

1 Like

Which version of Dune are you using? Do you have an .opam file in your directory? It may be easier to diagnose the problem if you give full details of your setup.

Cheers,
Nicolas

1 Like