dune icon indicating copy to clipboard operation
dune copied to clipboard

dune install -p <pkg> requires every packages from the project to be installed, not just <pkg>

Open kit-ty-kate opened this issue 3 years ago • 6 comments

Expected Behavior

With 3 packages into one repository, 2 of the packages available globally, I would expect dune install -p pkg3 to succeed and to only install pkg3.

Actual Behavior

Fails with:

Error: The following <package>.install are missing:
- _build/default/current_ocluster.install
- _build/default/ocluster-api.install
Hint: try running: dune build @install

and if we do dune build @install as hinted, all 3 packages are install/reinstalled (overriding globally installed packages, breaking the expectation of -p)

Reproduction

FROM ocaml/opam:debian
RUN git clone git://github.com/ocurrent/ocluster.git
WORKDIR ocluster
RUN git submodule update --init
RUN sudo ln -f /usr/bin/opam-2.1 /usr/bin/opam
RUN opam pin add -n .
RUN opam update --depexts
RUN opam install dune.2.8.5
RUN opam install --deps-only ocluster
RUN opam exec -- dune build -p ocluster
RUN opam exec -- dune install -p ocluster

Specifications

  • Version of dune (output of dune --version): 2.8.5

kit-ty-kate avatar Jul 16 '21 12:07 kit-ty-kate

It is indeed not taken into account and it should if it is an available option. But I wonder if there is a meaningfull difference between dune install ocluster and dune install --only-package ocluster, and I don't see which effect --release should have on the install command.

bobot avatar Sep 09 '21 08:09 bobot

@kit-ty-kate Do you think it would be OK to remove -p from the install command, or making dune install -p foo an alias of dune install foo.

bobot avatar Nov 21 '21 15:11 bobot

Sure, an alias would be perfectly fine I think. However I think the hint given on errors should also change accordingly. If dune install <pkg> or dune install -p <pkg> is given, the hint should be:

Hint: try running: dune build -p <pkg> @install

not

Hint: try running: dune build @install

kit-ty-kate avatar Nov 21 '21 16:11 kit-ty-kate

I'm not sure for the hint. I agree the current is wrong in some case, but the proposed one is also wrong in others (when the other libraries are not installed).

So we can have dune install -p <pkg> -> dune build -p <pkg> @install and dune install <pkg> -> dune build @install. But since dune install -p <pkg> and dune install <pkg> should be equivalent, I would prefer to write Hint: try running: dune build [-p <pkg>] @install, what do you think?

bobot avatar Nov 21 '21 16:11 bobot

Hi, got hit by this today and it took my quite a while to understand what went wrong. I think it's worth implementing the hint of some sort to help people understand this issue.

fangyi-zhou avatar Jul 12 '22 16:07 fangyi-zhou

Finally the alias proposition seems the most sensible. So MR would be accepted for dune install -p <pkg> an alias for dune install <pkg>.

bobot avatar Jul 13 '22 08:07 bobot

Yes, the bug is that we're accepting -p as an argument at all.

rgrinberg avatar Jan 31 '24 18:01 rgrinberg

FTR, it's going to be more difficult than expected because dune sites uses that in their installation instructions: https://github.com/ocaml/dune/blob/3.13.0/src/dune_rules/opam_create.ml#L62

emillon avatar Feb 01 '24 14:02 emillon