dune
dune copied to clipboard
dune pkg ignores :dev dependencies
Expected Behavior
dune utop works
Actual Behavior
dune utop
Building ocaml.5.2.0
File "_build/default", line 1, characters 0-0:
Error: Library "utop" not found.
-> required by _build/default/.utop/utop.bc
Reproduction
1.dune init project dune_utop_test
1.cd dune_utop_test
1.Change the depends line to (depends ocaml dune (utop :dev))
1.dune pkg lock
1.dune build
1.dune utop
Specifications
- Version of
dune(output ofdune --version):
"Dune Developer Preview: build 2024-09-28T01:30:13+00:00, git revision
17071ec30d10390badcb6cb1f6a43984b1be54a6"
- Version of
ocaml(output ofocamlc --version):
dune exec ocamlc -- --version
5.2.0
- Operating system (distribution and version): Fedora 40
Additional information
Would be good if utop and other "tools" could be added to the "dev dependencies" lock, without actually becoming visible/available for the project itself.
opam doesn't really have good support for this either (there is some limited support for installing e.g. the opam monorepo plugin into a tools switch?), but the new dune preview seems to support separate developer tool lockfiles, where tools like the LSP server, and ocamlformat go.
Actually I'm not sure whether :dev depencies would be the right way to support utop, they're probably more appropriate for optional dependencies (e.g. benchmarking tools) that you do want available in your build environment to activate various optional build rules.
dune already has a dune utop subcommand, so it'd be good if that installed utop as a dev tool automatically, just like how dune fmt installs ocamlformat.
I think the right way in OPAM parlance is to mark these dependencies is to use the :with-dev-setup variable.
FWIW, dune pkg also ignores :with-dev-setup.
Hello, is there a workaround before this is fixed?
I've tried manually installing utop with opam, but dune still doesn't pick it up.
After opam install utop, dune utop still complains Library "utop" not found.
@blurrcat Are you sure it is installed in the right switch? That should work, since it is independent of dune pkg.
That was my understanding too, but it didn't work.
I'm using a local switch:
➜ which utop
/home/han/workspace/golden-sheaf/_opam/bin/utop
➜ which dune
/home/han/workspace/golden-sheaf/_opam/bin/dune
When running dune utop
➜ opam exec -- dune utop # or just `dune utop`
File "_build/default", line 1, characters 0-0:
Error: Library "utop" not found.
-> required by _build/default/.utop/utop.bc
This is what I have in my dune-project:
(utop :with-dev-setup)
If I remove with-dev-setup and rebuild, dune utop does work.
FWIW,
dune pkgalso ignores:with-dev-setup.
Hi, in case this helps someone, I have seen also evidences of this with a recent version of nightly (downloaded yesterday).
I am using a workaround for now which consist of having a ${PROJECT}-dev.opam file in the project, where I list here the dependencies of the ${PROJECT}.opam that are specified as :with-dev-setup. The key to make that work is that in the -dev.opam version of the file, these dependencies are not qualified as :with-dev-setup. This seems to do the trick for now!
I'm closing this in favor of https://github.com/ocaml/dune/issues/12135 , since it has more analysis of the proposed solution.