dune icon indicating copy to clipboard operation
dune copied to clipboard

`dune utop` in a `dune pkg` managed workspace can fail with unmet library dependencies

Open shonfeder opened this issue 5 months ago • 1 comments

Expected Behavior

dune utop runs correctly, with all needed libraries available.

Actual Behavior

$ dune utop
Fatal error: exception Fl_package_base.No_such_package("logs.lwt", "required by `utop'")
↳[2]

Reproduction

Using this dune-project:

(lang dune 3.20)

(name repro)

(generate_opam_files true)

(source
 (github username/reponame))

(authors "Author Name <[email protected]>")

(maintainers "Maintainer Name <[email protected]>")

(license LICENSE)

(documentation https://url/to/documentation)

(package
 (name repro)
 (synopsis "A short synopsis")
 (description "A longer description")
 (depends ocaml mdx)
 (tags
  ("add topics" "to describe" your project)))

Then run

$ dune pkg lock; dune exec foo; dune utop

(The dune exec foo needed to get dune to actually build and install the deps.

Specifications

[17:11:41 ~]
$ dune --version
"Dune Developer Preview: build 2025-08-07T03:01:02Z, git revision
93f76bedb5044fda66446579af32a9a5f33a3f37"
↳[0]

Additional information

I suspect the problem arises from inconsistent assumptions around test-only dependencies. mdx depends on lwt :with-test, and apparently utop picks up this requirement, but the dependency is not actually installed in the project:

$ ls _build/_private/default/.pkg/
astring       camlp-streams  csexp  mdx                  ocamlbuild      ocamlfind      result
base-threads  cmdliner       fmt    ocaml                ocaml-compiler  ocaml-version  seq
base-unix     cppo           logs   ocaml-base-compiler  ocaml-config    re             topkg

shonfeder avatar Aug 08 '25 21:08 shonfeder

Support for dune utop in the context of dune pkg was added in https://github.com/ocaml/dune/pull/12027, so presumably this just calls for a minor revision for an edge case.

shonfeder avatar Aug 08 '25 21:08 shonfeder