ocaml / opam-repository

Main public package repository for opam, the source package manager of OCaml.
https://opam.ocaml.org
Creative Commons Zero v1.0 Universal
516 stars 1.12k forks source link

Syntax for conjunction in conflict #15441

Open maroneze opened 4 years ago

maroneze commented 4 years ago

I am adding a conflicts clause to a package due to issue #10925, otherwise our users will end up trying to compile Frama-C and fail.

I tried adding this to our conflicts:

("ocamlfind" { = "1.8.1" } & "ocaml" { = "4.05.0" })

Which means, only if both OCaml is 4.05.0 and ocamlfind is 1.8.1, should the conflict happen.

However, when testing locally via opam pin add -kind path, each element seems to be parsed individually, so when testing with OCaml 4.05.0 and ocamlfind 1.8.0, I get:

Your request can't be satisfied:
  - conflict with the base packages of this switch

I also tried a different syntax:

"ocamlfind" { = "1.8.1" & ocaml:version = "4.05.0" }

opam lint did not complain, but this time it did not prevent installation when the clause was true.

I also tried adding some constraints to depends:

"ocamlfind" { != "1.8.1" | "ocaml" != "4.05.0" }

But again, these were ignored.

Is there a way to specify this kind of constraint?

maroneze commented 4 years ago

For now, I'm following a colleague's suggestion, and using the messages field to emit a warning when both conditions are met. This will not prevent the user from installing the package, but should be explicit enough that they would have some information before trying to compile the package.

I'm leaving the issue open because I'm still interested in a solution for the general case.

emillon commented 4 years ago

I think you can adapt your message solution by adding a failing command to the build instructions if both conditions are set:

["false" {ocamlfind:version = "1.8.1" & ocaml:version = "4.05.0"]

(this is has the same limitations, ie this will be considered a valid solution by the solver, so it won't try anything else)

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or comment, or this will be closed in 15 days.