Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The <package> Doesn't build with dune error is omitted from the output of opam monorepo lock in some cases #385

Open
gridbugs opened this issue Apr 28, 2023 · 0 comments · May be fixed by #390

Comments

@gridbugs
Copy link
Collaborator

When a package depends on a non-dune package and a specific version of the compiler the error message displayed when running opam monorepo lock does not mention the fact that the failure was due to a dependency on a non-dune package. For example, locking the following package:

opam-version: "2.0"
depends: [
  "ansicolor"              # ansicolor does not depend on dune
  "ocaml" {= "4.14.1"}
]

The error message will be (the package name was "qux"):

opam_monorepo.exe: [ERROR] Can't find all required versions.
Selected: base-bigarray.base base-domains.base base-nnp.base
          base-threads.base base-unix.base ocaml-config.3
          ocaml-options-vanilla.1 ocaml-base-compiler&qux ocaml-base-compiler
          ocaml-base-compiler ocaml base-domains ocaml-base-compiler
- ocaml -> ocaml.5.0.0
    ocaml-base-compiler 5.0.0 requires = 5.0.0
- ocaml-base-compiler -> ocaml-base-compiler.5.0.0
    ocaml-base-compiler|ocaml-variants|ocaml-system ocaml-base-compiler requires >= 5.0.0~ & < 5.0.1~
- qux -> (problem)
    Rejected candidates:
      qux.zdev: Requires ocaml = 4.14.1

The only problem with this package is that the dependency ansicolor does not build with dune, but the error message could lead users in the wrong direction when debugging this issue.

The expected error message is (prior to 46b287f):

opam_monorepo.exe: [ERROR] Can't find all required versions.
Selected: base-bigarray.base base-domains.base base-nnp.base
          base-threads.base base-unix.base ocaml-config.3
          ocaml-options-vanilla.1 qux.zdev ocaml-base-compiler&qux
          ocaml-base-compiler ocaml-base-compiler ocaml base-domains
          ocaml-base-compiler
- ansicolor -> (problem)
    No usable implementations:
      ansicolor.0.5: Doesn't build with dune
- ocaml -> ocaml.5.0.0
    ocaml-base-compiler 5.0.0 requires = 5.0.0
- ocaml-base-compiler -> ocaml-base-compiler.5.0.0
    ocaml-base-compiler|ocaml-variants|ocaml-system ocaml-base-compiler requires >= 5.0.0~ & < 5.0.1~

Note the ansicolor.0.5: Doesn't build with dune, which is omitted in the original error message.

After commit 46b287f the error message is expected to be:

opam_monorepo.exe: [ERROR] Some dependencies cannot be built with dune!

opam-monorepo requires that all dependencies use dune as their build system.

These dependencies (possibly transitive) don't use dune as their build system:
- ansicolor

The dune-universe opam repository (git+https://github.com/dune-universe/opam-overlays.git) contains dune ports of some popular packages to help build more packages with dune however it appears to already be set up on this switch. Thus it is possible that no dune port exists for any of these packages.

For information on how to contribute a new dune port, see: https://github.com/dune-universe/opam-overlays

Removing the version constraint on the "ocaml" package causes the problem to go away.

Note that on the latest release of opam-monorepo (0.3.5) this error doesn't seem to happen, though opam monorepo lock succeeds with no error message and proceeds to generate a lockfile which doesn't download ansicolor at all, which I assume was a bug that has since been fixed.

My hypothesis for why this is happening is after the solver concludes that no solution is possible, it gets run again, passing ~closest_match:true (https://github.com/ocaml-opam/opam-0install-solver/blob/a17703ba83374975633d66bea2d40da51beabee5/lib/solver.ml#L57). The solver doesn't know that it's more useful to pick a partial solution whose diagnostics will include the fact that it failed due to a package having no versions that build with dune.

@gridbugs gridbugs changed the title The <package> Doesn't build with dune error is omitted from opam monorepo lock in some cases The <package> Doesn't build with dune error is omitted from the output of opam monorepo lock in some cases Apr 28, 2023
gridbugs added a commit to gridbugs/opam-monorepo that referenced this issue Apr 28, 2023
This is a workaround for
tarides#385. The error message
displayed when a dependency doesn't build with dune is misleading in
some cases. This adds a check that direct dependencies all have
available versions which build with dune before running the solver.
@gridbugs gridbugs linked a pull request May 26, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant