ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.63k stars 409 forks source link

dune pkg ignores :dev dependencies #10973

Open edwintorok opened 1 month ago

edwintorok commented 1 month ago

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

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.

edwintorok commented 1 month ago

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.

Leonidas-from-XIV commented 1 month ago

I think the right way in OPAM parlance is to mark these dependencies is to use the :with-dev-setup variable.