opam-repository icon indicating copy to clipboard operation
opam-repository copied to clipboard

Syntax for conjunction in conflict

Open maroneze opened this issue 5 years ago • 3 comments

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 avatar Dec 03 '19 17:12 maroneze

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.

maroneze avatar Dec 04 '19 12:12 maroneze

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)

emillon avatar Jan 09 '20 14:01 emillon

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.

github-actions[bot] avatar Apr 21 '20 09:04 github-actions[bot]