Skip to content

Commit

Permalink
Fix misleading error message for non-dune dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
gridbugs committed May 26, 2023
1 parent c088927 commit 9cd5075
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
commands, as some non-virtual packages might only have install commands.
(#376 @Leonidas-from-XIV, @gridbugs)

- Fix bug where a misleading error message would be displayed in some cases
where a dependency doesn't build with dune (#???,
fixes #385, @gridbugs)

### Removed

### Security
Expand Down
8 changes: 7 additions & 1 deletion lib/opam_solve.ml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,13 @@ let mk_request ~allow_compiler_variants packages =
released yet but that exists in opam with variants such as
ocaml-variants.x+trunk *)
let base_compiler = OpamPackage.Name.of_string "ocaml-base-compiler" in
base_compiler :: package_names
(* It is important that the compiler package appears after the user's
package names. Otherwise in cases where no solution can be found, the
solver seems to report errors relating to the ocaml compiler rather than
the user-controlled dependencies (see
https://github.com/tarides/opam-monorepo/issues/385 for an example of
this problem). *)
package_names @ [ base_compiler ]

let depend_on_compiler_variants local_packages =
OpamPackage.Name.Map.exists
Expand Down
32 changes: 18 additions & 14 deletions test/bin/github385.t/run.t
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
This is a reproduction of a problem where depending on a specific version of the
ocaml compiler at the same time as a package that doesn't build with dune leads
to an error message that doesn't mention the fact that the problem is due to the
non-dune dependency, despite the fact that removing that dependency or adding
an overlay containing a suitable dune port for the package causes the problem to
go away.
This test asserts that the issue at
https://github.com/tarides/opam-monorepo/issues/385 is fixed.

The problem was that depending on a specific version of the ocaml compiler at
the same time as a package that doesn't build with dune leads to an error
message that doesn't mention the fact that the problem is due to the non-dune
dependency, despite the fact that removing that dependency or adding an overlay
containing a suitable dune port for the package causes the problem to go away.

$ gen-minimal-repo

$ opam-monorepo lock
==> Using 1 locally scanned package as the target.
opam-monorepo: [ERROR] Can't find all required versions.
Selected: base-bigarray.base base-threads.base base-unix.base ocaml.4.13.1
ocaml-base-compiler.4.13.1 ocaml-config.2 ocaml-options-vanilla.1
ocaml-base-compiler&foo ocaml-base-compiler ocaml-base-compiler
ocaml-base-compiler
- foo -> (problem)
Rejected candidates:
foo.zdev: Requires ocaml = 4.14.1
opam-monorepo: [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:
- without-dune
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
[1]

0 comments on commit 9cd5075

Please sign in to comment.