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.21k stars 347 forks source link

Improved error messages in the case of a missing dependency #4754

Open RichardWarburton opened 2 years ago

RichardWarburton commented 2 years ago

Hi,

I've been testing out a local library against a project with a custom switch that uses an opam repository that is missing the opam dependency conf-g++ (found in https://github.com/ocaml/opam-repository/) and when you try to pin or install the library into this core project it fails with the following error:

[NOTE] Pinning command successful, but your installed packages may be out of sync. Sorry, no solution found: there seems to be a problem with your request.

I would expect to be given a more explicit description of the problem here, so something like cannot find package "conf-g++".

I'm using opam version 2.0.5.

rjbou commented 2 years ago

I tried to reproduce, but I have a good error message :

The following dependencies couldn't be met:
  - known → dontexist
      unknown package

My test case is a pinned package known with a dependency that doesn't exist dontexist (not in repo nor pinned), and I have this message with a pinning or an install. Can you precise you use case ?

RichardWarburton commented 2 years ago

Perhaps it's because it was a build dependency? Here's the depends section of my .opam file:

depends: [
  "dune" {>= "2.7"}
  "ocaml" {>= "4.12.0"}
  "conf-g++"    {build}
]

The repository was https://gitlab.com/tezos/opam-repository/

If there's any other information that can help you narrow down the issue then let me know.

rjbou commented 2 years ago

It is intriguing, I can't reproduce, even as a build dependency (it doesn't affect dependencies set, but actions and their order mainly). I created a switch with tezos repo (only) and pinned a package with those exact dependencies, and I have the same message with unknown package.

rjbou commented 2 years ago

Maybe you have in your switch some package installed with some constraints, that conflicts with the new one? In my case the switch is empty.

RichardWarburton commented 2 years ago

I see. In terms of other differences: Are you also using opam 2.0.5?

Here is an export of my switch (having removed the dev library that I was trying to install)

opam-version: "2.0"
compiler: [
  "base-bigarray.base"
  "base-threads.base"
  "base-unix.base"
  "ocaml.4.12.0"
  "ocaml-base-compiler.4.12.0"
  "ocaml-config.2"
  "ocaml-options-vanilla.1"
]
roots: ["ocaml-base-compiler.4.12.0"]
installed: [
  "alcotest.1.4.0"
  "alcotest-lwt.1.4.0"
  "angstrom.0.15.0"
  "asn1-combinators.0.2.5"
  "astring.0.8.5"
  "base.v0.14.1"
  "base-bigarray.base"
  "base-bytes.base"
  "base-threads.base"
  "base-unix.base"
  "base64.3.5.0"
  "bheap.2.0.0"
  "bigarray-compat.1.0.0"
  "bigstring.0.3"
  "bigstringaf.0.7.0"
  "biniou.1.2.1"
  "bisect_ppx.2.6.0"
  "bls12-381.0.4.3"
  "bls12-381-gen.0.4.3"
  "bls12-381-unix.0.4.3"
  "camlzip.1.10"
  "cmdliner.1.0.4"
  "cohttp.4.0.0"
  "cohttp-lwt.4.0.0"
  "cohttp-lwt-unix.4.0.0"
  "conduit.2.1.0"
  "conduit-lwt.2.1.0"
  "conduit-lwt-unix.2.2.2"
  "conf-autoconf.0.1"
  "conf-gmp.3"
  "conf-gmp-powm-sec.3"
  "conf-hidapi.0"
  "conf-libev.4-12"
  "conf-libffi.2.0.0"
  "conf-perl.1"
  "conf-pkg-config.2"
  "conf-rust.0.1"
  "conf-which.1"
  "conf-zlib.1"
  "coq-of-ocaml.2.5.0"
  "cppo.1.6.7"
  "csexp.1.5.1"
  "cstruct.6.0.0"
  "cstruct-lwt.6.0.0"
  "cstruct-sexp.6.0.0"
  "ctypes.0.18.0"
  "ctypes-foreign.0.18.0"
  "data-encoding.0.4"
  "digestif.1.0.0"
  "domain-name.0.3.0"
  "dum.1.0.1"
  "dune.2.8.5"
  "dune-build-info.2.8.5"
  "dune-configurator.2.8.5"
  "duration.0.1.3"
  "easy-format.1.3.2"
  "either.1.0.0"
  "eqaf.0.7"
  "ezjsonm.1.2.0"
  "ff-sig.0.6.1"
  "fix.20201120"
  "fmt.0.8.9"
  "fpath.0.7.3"
  "genspio.0.0.2"
  "gmap.0.3.0"
  "hacl-star.0.3.2"
  "hacl-star-raw.0.3.2"
  "hashcons.1.3"
  "hex.1.4.0"
  "hidapi.1.1.1"
  "hkdf.1.0.4"
  "index.1.4.0"
  "integers.0.4.0"
  "ipaddr.5.0.1"
  "ipaddr-sexp.5.0.1"
  "irmin.2.7.0"
  "irmin-layers.2.7.0"
  "irmin-pack.2.7.0"
  "jane-street-headers.v0.14.0"
  "jbuilder.1.0+beta20.2"
  "js_of_ocaml.3.9.0"
  "js_of_ocaml-compiler.3.9.1"
  "js_of_ocaml-ppx.3.9.0"
  "json-data-encoding.0.9.1"
  "json-data-encoding-bson.0.9.1"
  "jsonm.1.0.1"
  "jst-config.v0.14.0"
  "logs.0.7.0"
  "lwt.5.4.1"
  "lwt-canceler.0.3"
  "lwt-exit.1.0"
  "lwt-watcher.0.1"
  "lwt_log.1.1.1"
  "macaddr.5.0.1"
  "magic-mime.1.1.3"
  "menhir.20210419"
  "menhirLib.20210419"
  "menhirSdk.20210419"
  "mirage-crypto.0.10.1"
  "mirage-crypto-ec.0.10.1"
  "mirage-crypto-pk.0.10.1"
  "mirage-crypto-rng.0.10.1"
  "mirage-no-solo5.1"
  "mirage-no-xen.1"
  "mmap.1.1.0"
  "mtime.1.2.0"
  "nonstd.0.0.3"
  "num.1.4"
  "ocaml.4.12.0"
  "ocaml-base-compiler.4.12.0"
  "ocaml-compiler-libs.v0.12.3"
  "ocaml-config.2"
  "ocaml-migrate-parsetree.2.1.0"
  "ocaml-options-vanilla.1"
  "ocaml-syntax-shims.1.0.0"
  "ocaml-version.3.1.0"
  "ocamlbuild.0.14.0"
  "ocamlfind.1.9.1"
  "ocamlformat.0.18.0"
  "ocamlgraph.2.0.0"
  "ocp-ocamlres.0.4"
  "ocplib-endian.1.1"
  "octavius.1.2.2"
  "odoc.1.5.2"
  "opam-depext.1.1.5"
  "opsian.~dev"
  "optint.0.1.0"
  "parsexp.v0.14.0"
  "pbkdf.1.1.0"
  "pprint.20200410"
  "ppx_assert.v0.14.0"
  "ppx_base.v0.14.0"
  "ppx_cold.v0.14.0"
  "ppx_compare.v0.14.0"
  "ppx_cstruct.6.0.0"
  "ppx_derivers.1.2.1"
  "ppx_deriving.5.2.1"
  "ppx_enumerate.v0.14.0"
  "ppx_hash.v0.14.0"
  "ppx_here.v0.14.0"
  "ppx_inline_test.v0.14.1"
  "ppx_irmin.2.7.0"
  "ppx_js_style.v0.14.0"
  "ppx_optcomp.v0.14.1"
  "ppx_repr.0.4.0"
  "ppx_sexp_conv.v0.14.3"
  "ppx_tools.6.3"
  "ppxlib.0.22.0"
  "progress.0.1.1"
  "ptime.0.8.5"
  "pyml.20210226"
  "qcheck-alcotest.0.17"
  "qcheck-core.0.17"
  "re.1.9.0"
  "repr.0.4.0"
  "resto.0.6.1"
  "resto-acl.0.6.1"
  "resto-cohttp.0.6.1"
  "resto-cohttp-client.0.6.1"
  "resto-cohttp-self-serving-client.0.6.1"
  "resto-cohttp-server.0.6.1"
  "resto-directory.0.6.1"
  "result.1.5"
  "ringo.0.5"
  "ringo-lwt.0.5"
  "rresult.0.6.0"
  "secp256k1-internal.0.2.0"
  "semaphore-compat.1.0.1"
  "seq.base"
  "sexplib.v0.14.0"
  "sexplib0.v0.14.0"
  "smart-print.0.3.0"
  "sosa.0.3.0"
  "stdcompat.15"
  "stdio.v0.14.0"
  "stdlib-shims.0.3.0"
  "stringext.1.6.0"
  "tar.1.1.0"
  "tar-unix.1.1.0"
  "terminal_size.0.1.4"
  "tezos-rust-libs.1.1"
  "time_now.v0.14.0"
  "tls.0.13.1"
  "topkg.1.0.3"
  "tyxml.4.5.0"
  "uchar.0.0.2"
  "uri.4.2.0"
  "uri-sexp.4.2.0"
  "uucp.13.0.0"
  "uuidm.0.9.7"
  "uuseg.13.0.0"
  "uutf.1.0.2"
  "x509.0.13.0"
  "yojson.1.7.0"
  "zarith.1.11"
  "zarith_stubs_js.v0.14.0"
]
rjbou commented 2 years ago

Yes, using 2.0.5, and even with this switch I have the unknown package error message. The only difference is that you have in your switch a package named opsian, what are its dependencies?

RichardWarburton commented 2 years ago

Those were the dependencies I mentioned earlier:

 depends: [
  "dune" {>= "2.7"}
  "ocaml" {>= "4.12.0"}
  "conf-g++"    {build}
]
rjbou commented 2 years ago

For reproducibility it is better to set up dockerfiles. Here what I got, with the information I have, and it is working:

FROM ocaml/opam
RUN bash -c 'echo | sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/aff0987fb4804cff63e8882ed99795bf87bc4c8b/shell/install.sh)'
RUN opam --version
RUN opam repository set-url default git+https://gitlab.com/tezos/opam-repository
RUN opam switch create unknown-package --empty
# switch-import is the file of the exported switch
COPY switch-import switch-import
RUN opam switch import ./switch-import --fake #fake install, have no effect on availability
RUN mkdir opsian
RUN echo ' opam-version: "2.0" depends: [ "dune" {>= "2.7"} "ocaml" {>= "4.12.0"} "conf-g++"    {build} ]' > opsian.opam
RUN opam pin ./opsian

Can you check?