dune icon indicating copy to clipboard operation
dune copied to clipboard

Error solving project with deps specified in opam file when deps contain a disjunction

Open gridbugs opened this issue 1 year ago • 3 comments

If a project defines a local package in an opam file instead of its dune-project file, and the opam file specifies a disjunction of packages among its dependencies, dune prints an error while solving:

Error: Expected formula to be a conjunction of atoms but encountered non-atom
term 'extlib {build} | extlib-compat {build}'

To reproduce:

$ opam source lutin.2.71.15
$ cd lutin.2.71.15
$ dune pkg lock
File "lutin.opam", line 1, characters 0-0:
Error: Expected formula to be a conjunction of atoms but encountered non-atom
term 'extlib {build} | extlib-compat {build}'

The package lutin contains this disjunction in its dependencies:

"extlib" {build} | "extlib-compat" {build}

Note that there's no way to describe a package disjunction in the DSL for specifying dependencies in dune-project, but opam files allow it. Dune can handle the case when an external package (ie. a dependency of the project) has a package disjunction in its dependencies, but not when the current project itself has a package disjunction in its dependencies.

I think it would be valid to just improve the error message here to make it clear that this case is not supported.

gridbugs avatar Aug 20 '24 05:08 gridbugs

Improving the error message is a good first step. Although there's no fundamental reason not to support this. If a package uses opam to define its metadata, then it should not be a problem for us to pass along the metadata to the solver without interpreting anything.

rgrinberg avatar Aug 20 '24 09:08 rgrinberg

This same error also occurs when trying to build some highly dependend-upon packages:

Package functoria-runtime (4340 revdeps) fails with

---> Building package n°18: package "functoria-runtime.4.4.2":
Successfully extracted to /tmp/pkg-coverage-f9e828-builder/functoria-runtime.4.4.2
File "mirage-runtime.opam", line 1, characters 0-0:
Error: Expected formula to be a conjunction of atoms but encountered non-atom
term 'result < "1.5" | ppxlib = "0.29.0"'

Package io-page (4340 revdeps) fails with

---> Building package n°22: package "io-page.3.0.0":
Successfully extracted to /tmp/pkg-coverage-9be759-builder/io-page.3.0.0
File "io-page.opam", line 1, characters 0-0:
Error: Expected formula to be a conjunction of atoms but encountered non-atom
term 'mirage-xen < "6.0.0" | ocaml-freestanding < "0.4.1"'

The revdep count is according to check.ci.ocaml.org

ElectreAAS avatar Aug 28 '24 14:08 ElectreAAS

I looked at it and this looks like it should be fairly easy to fix as we parse the dependencies from a filtered_formula into an dependency set, use this set mostly for hashing and taking out a random element and then reconstruct a filtered_formula to give to the solver.

Leonidas-from-XIV avatar Sep 11 '24 15:09 Leonidas-from-XIV