dune icon indicating copy to clipboard operation
dune copied to clipboard

`dune tools install` should take multiple package arguments

Open shonfeder opened this issue 2 months ago • 2 comments

Desired Behavior

dune tools install a b c

should install the dev tools a, b, and c.

Example

E.g.,

dune tools install ocamllsp ocamlformat

Instead, this currently reports

dune: too many arguments, don't know what to do with 'ocamlformat'

shonfeder avatar Oct 12 '25 17:10 shonfeder

Just looked at this with @Sudha247 who explained that the current Cmdliner term treats each installable as a subcommand for some reason, constructed here:

https://github.com/ocaml/dune/blob/84e0722baf93a763fb82fb3d234ead55e930ab6a/bin/tools/tools_common.ml#L114-L125

We think there should be no reason this can't be rewritten to instead take a list of arguments here:

https://github.com/ocaml/dune/blob/84e0722baf93a763fb82fb3d234ead55e930ab6a/bin/tools/group.ml#L23-L30

shonfeder avatar Nov 25 '25 17:11 shonfeder

I have a patch for this here: https://github.com/Sudha247/dune/tree/dune-tools-multiple-arguments. It includes a cram test, which currently fails because it's unable to find the subsequent packages after the first package.

Install the dev tools
 |
 |$ dune tools install ocamllsp ocamlformat
 |  $ dune tools install ocamlformat ocamllsp
+|  Solution for _build/.dev-tools.locks/ocamlformat:
+|  - ocamlformat.0.0.1
+|  Solution for _build/.dev-tools.locks/ocaml-lsp-server:
+|  - ocaml.5.2.0
+|  - ocaml-lsp-server.0.0.1
+|  Error: Unknown package this "ocaml-lsp-server"
+|  I didn't find the package

We looked at it a bit with @Leonidas-from-XIV, and concluded that the solver is not able to find the second package from the DB here: https://github.com/ocaml/dune/blob/7c53739170c4131e3ca58ca522b02174db59d2da/src/dune_rules/pkg_rules.ml#L1460-L1462

However, I'm not sure whether this is the expected behaviour. I'll dig further into this, and if anyone has thoughts that would be useful.

Sudha247 avatar Dec 02 '25 16:12 Sudha247