ocaml / ocaml/dune

(allow_empty) rules and messages are confusing

Open
#8,352 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

I was trying to build https://github.com/TyOverby/sdui, and got the following error message:

Error: The package sdui 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/sdui.install
-> required by alias all
-> required by alias default

For context, the project consists of an executable compiled with (modes js)

There's a few issues here:

  1. (allow_empty) is not documented at all #5567, and is not highlighted/suggested by VSCode's dune syntax highlighting and autofill.
  2. The wording "user defined stanzas" is confusing. At first I thought that maybe the dune file was empty (or undefined), but that wasn't the case. I'm assuming it's trying to say that nothing is made importable via public_name, but I only pieced that together by looking at other support questions with the same issue.
  3. The suggested fix in support forums is to add a (public_name<s>) stanza to (executable<s>). But that's not allowed for (modes js).
  4. Should projects that consist entirely of executables not have (package) stanzas or opam files? From my limited experience with OCaml, my impression was that dune-project and opam files are mandatory for building, dependency-locking, locally installing, and setting metadata for any OCaml project, not just ones where code can be used by other projects.

Reproduction

dune-project:

(lang dune 3.10)

(name test)

(package
 (name test))

dune:

(executable
 (name main))

main.ml:

let () = print_string "test"

Specifications

  • Version of dune (output of dune --version): 3.10.0
  • Version of ocaml (output of ocamlc --version): 4.14.1
  • Operating system (distribution and version): Ubuntu 22.04.3 LTS

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal reproduction with dune-project, dune, and main.ml from the issue, then inspect the package validation and error-message paths for allow_empty. Check how the option is documented and how executable-only projects using (modes js) are handled. Done should mean the guidance and wording are accurate, and the relevant package behavior is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.