ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.24k stars 356 forks source link

Can't understand unmet dependency errors #3568

Open LucaFranceschini opened 6 years ago

LucaFranceschini commented 6 years ago
# opam config report
# opam-version      2.0.0 
# self-upgrade      no
# system            arch=x86_64 os=linux os-distribution=arch os-version=unknown
# solver            builtin-mccs+glpk
# install-criteria  -removed,-count[version-lag,request],-count[version-lag,changed],-changed
# upgrade-criteria  -removed,-count[version-lag,solution],-new
# jobs              3
# repositories      1 (http) (default repo at 67636479)
# pinned            0
# current-switch    default

I just installed opam:

$ opam list
# Packages matching: installed
# Name        # Installed # Synopsis
base-bigarray base        Bigarray library distributed with the OCaml compiler
base-threads  base        Threads library distributed with the OCaml compiler
base-unix     base        Unix library distributed with the OCaml compiler
ocaml         4.07.0      The OCaml compiler (virtual package)
ocaml-system  4.07.0      The OCaml compiler (system version, from outside of opam)

Installing ocaml-top fails as follows:

$ opam install ocaml-top
The following dependencies couldn't be met:
  - ocaml-top → ocaml < 4.06.0
      base of this switch (use `--unlock-base' to force)
  - ocaml-top → ocp-build (< 1.99.8-beta | < 1.99.8-beta)
      no matching version
  - ocaml-top → ocp-index >= 1.0.0 → ocaml < 4.07
      base of this switch (use `--unlock-base' to force)

No solution found, exiting

I am not sure I understand the messages here:

What am I missing?

dra27 commented 6 years ago

opam is telling you what constraints failed while it searched packages to attempt to solve the installation, not repeating constraints from the description itself. What is confusing is that it doesn't tell you the actual version it was considering, but I think there's a reason for that.

The fundamental problem here is that ocp-index is not available for 4.07.0. It's not displaying the ">= 4.01.0" because your switch satisfies that constraint.

The other ones arise from when the solver considers other versions of ocaml-top. The second one arose when it considered ocaml-top 1.1.0, since it contains an unsatisfiable dependency on ocp-build, caused by https://github.com/ocaml/opam-repository/pull/3491, and the first when ocaml-top 1.1.4 was considered (which is the only version which has an upperbound on the compiler version)

LucaFranceschini commented 6 years ago

opam is telling you what constraints failed while it searched packages to attempt to solve the installation, not repeating constraints from the description itself. What is confusing is that it doesn't tell you the actual version it was considering, but I think there's a reason for that.

The fundamental problem here is that ocp-index is not available for 4.07.0. It's not displaying the ">= 4.01.0" because your switch satisfies that constraint.

The other ones arise from when the solver considers other versions of ocaml-top. The second one arose when it considered ocaml-top 1.1.0, since it contains an unsatisfiable dependency on ocp-build, caused by ocaml/opam-repository#3491, and the first when ocaml-top 1.1.4 was considered (which is the only version which has an upperbound on the compiler version)

Ok, the real issue is the last one, this makes sense. Thanks.

The search for other versions of the requested package is honestly quite surprising for a package manager: I would expect the install command to either use the last version of the requested package or to fail. Is this documented somewhere?

At the very least, I think it should print a message regarding what's going on.

dra27 commented 6 years ago

The search for other versions of the requested package is honestly quite surprising for a package manager: I would expect the install command to either use the last version of the requested package or to fail. Is this documented somewhere?

It's not surprising - any package manager with a constraint solver will do this. In particular, the current model means that you can continue to install packages in old versions of OCaml.

I'm not sure, @AltGr - is there enough information present to display the (or a) version of the package which is causing a particular constraint?

LucaFranceschini commented 6 years ago

It's not surprising - any package manager with a constraint solver will do this. In particular, the current model means that you can continue to install packages in old versions of OCaml.

It never happened to me with any other package manager, not by default at least.

Don't get me wrong, I get the usefulness of this feature. I just think that, whenever this happens, a package manager should clearly say that it failed to install the last version, which is what people expect from an "install" command.

shonfeder commented 4 years ago

I'm also finding the messaging of dependency resolution failures to be less helpful than they might otherwise be. What does the indicate in the message? It apparently doesn't mean "depends on" or "implies". Is it documented somewhere? Why is the last package in each line red? When it says "no version of foo satisfies the constraints", which part of the output is imposing the constraints?

What would be really helpful is a message like: "cannot install package foo because bar requires baz < 0.1 but qux requires baz > 0.1. Failing that, linking to some resource that explains how to decode this cryptic message would be helpful.