tarides / opam-monorepo

Assemble dune workspaces to build your project and its dependencies as a whole
ISC License
130 stars 27 forks source link

Simplify error message when deps don't build with dune #384

Closed gridbugs closed 1 year ago

gridbugs commented 1 year ago

When trying to generate a lockfile on a package which has dependencies which don't use dune as their build system, the diagnostic message generated by opam-0install is of little use. This change removes the opam-0install diagnostic message from the output of opam monorepo lock in the case where it fails due to dependencies not building with dune.

Additionally this rewords the error message to highlight the salient information. In particular the list of non-dune packages is printed as a bulleted list rather than a comma-separated list inside the error message (it often takes me a minute to find the list of packages in the old error message).

gridbugs commented 1 year ago

An example output of opam monorepo lock using this opam file:

opam-version: "2.0"
depends: [
  "cmdliner"
]

Before this change:

opam_monorepo.exe: [WARNING] Couldn't calculate a set of packages to satisfy the request. Note that opam monorepo lock will fail if not all of the project dependencies use dune as their build system, in your project that would be cmdliner. To solve this issue there exists a dune-universe opam-repository which contains dune ports for some opam packages, but it is currently not set in your current switch. If you wish to set it up, run the following command:
opam repository add dune-universe git+https://github.com/dune-universe/opam-overlays.git
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 package.zdev ocaml-base-compiler&package
          ocaml-base-compiler ocaml-base-compiler ocaml base-domains
          ocaml-base-compiler
- cmdliner -> (problem)
    No usable implementations:
      cmdliner.1.2.0: Doesn't build with dune
      cmdliner.1.1.1: Doesn't build with dune
      cmdliner.1.1.0: Doesn't build with dune
      cmdliner.1.0.4: Doesn't build with dune
      cmdliner.1.0.3: 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~

After this change:

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:
- cmdliner

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. It doesn't appear to be set up on this switch. Adding it to this switch may fix this issue. Add the dune-universe opam repository to this switch by running the command:

opam repository add dune-universe git+https://github.com/dune-universe/opam-overlays.git
Leonidas-from-XIV commented 1 year ago

Ehh, I see there's a CI failure. That needs to be updated, but it looks like it is just about the exact output of the command, not a fundamental property of the PR that it breaks something.