Note: Seeing as people have complained about this before, just to be clear, I’m not trying to suggest or accuse any software in the OCaml ecosystem of being implemented incorrectly, or doing something wrong. I have just run into a problem, and am asking for advice.
When using a local open that introduces a module with the same name as a module in the project, dune complains of a non-existent dependency cycle.
Example, consider a project with 3 files:
- database.ml
module Actor = struct
let version = 10
end
- helper.ml (depends on database.ml):
let project_version = Database.(Actor.version + 10)
- actor.ml (depends on helper.ml):
let actor_version = Helper.project_version + 20
When I try to build this project using dune, it complains about a dependency cycle:
Error: Dependency cycle between:
_build/default/failure.ml/.main.eobjs/dune__exe__Helper.impl.all-deps
-> _build/default/failure.ml/.main.eobjs/dune__exe__Actor.impl.all-deps
-> _build/default/failure.ml/.main.eobjs/dune__exe__Helper.impl.all-deps
If, for example, I replace the contents of helper.ml with the following (removing the parenthesis):
let project_version = Database.Actor.version + 10
The code compiles correctly.
Similarly, if I modify the contents of actor.ml as follows:
let actor_version = 20 (* no dependency on helper *)
The project compiles again, so the issue (again, not trying to claim that any software is implemented incorrectly, just having difficulty compiling my project) really does seem to be due to dune, not some peculiarity of the semantics of local opens.
I was thinking of submitting an issue (not suggesting that it has been implemented incorrectly, just if it turns out to indeed be a bug (which to be clear, I am not claiming)) to the dune git forge, but wasn’t sure if this was my own mistake.
Does anyone know if this is indeed a bug, or a mistake on my part?