ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.21k stars 348 forks source link

opam switch import doesn't set invariant #5933

Open Khady opened 2 months ago

Khady commented 2 months ago

tested with opam 2.1.2, I don't know what's the status with opam 2.2

I have an export file which contains

compiler: ["ahrefs-setup.git" "ocaml-base-compiler.4.14.0"]

I believe that it corresponds to the invariant of the switch, but I might be wrong.

If I do opam sw import --sw=. sw.export and opam sw invariant it appears that my switch has no invariant set.

I have to do opam sw import --sw=. sw.export --packages=ahrefs-setup,ocaml-base-compiler.4.14.0 to get things setup as expected.

kit-ty-kate commented 2 months ago

I confirm, this is still the case with opam 2.2

rjbou commented 2 months ago

Are you importing in a switch that already exist ?

kit-ty-kate commented 2 months ago

yes, but in any case it should be done. One thing that's also broken is that exporting a switch doesn't export the invariant, only the "compiler packages" so exporting/importing does result in the same invariant.

rjbou commented 2 months ago

The current workflow is to not update the invariant when the switch already exists. The idea behind is if the switch already exists, user already set the invariant. Imported switch will then result on pinning and trying to install mentioned packages. We could change that behaviour, but carefully as it will affect user switch, by asking for confirmation for example.

In the case where the switch doesn't exist, yes, the invariant should be the same than the previous switch. As the invariant is inferred, we need to add the information in the export file and update the format.

Khady commented 2 months ago

I had the issue when importing in a non existing switch I believe.

kit-ty-kate commented 2 months ago

That one particular case is fixed in 2.2 then (the rest is still to be fixed ofc)