(allow_empty) rules and messages are confusing
Open
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:
- (allow_empty) is not documented at all #5567, and is not highlighted/suggested by VSCode's dune syntax highlighting and autofill.
- The wording "user defined stanzas" is confusing. At first I thought that maybe the
dunefile was empty (or undefined), but that wasn't the case. I'm assuming it's trying to say that nothing is made importable viapublic_name, but I only pieced that together by looking at other support questions with the same issue. - 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). - Should projects that consist entirely of executables not have
(package)stanzas oropamfiles? From my limited experience with OCaml, my impression was thatdune-projectandopamfiles 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 ofdune --version): 3.10.0 - Version of
ocaml(output ofocamlc --version): 4.14.1 - Operating system (distribution and version): Ubuntu 22.04.3 LTS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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