opam icon indicating copy to clipboard operation
opam copied to clipboard

opam switch import doesn't set invariant

Open Khady opened this issue 1 year ago • 6 comments

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.

Khady avatar Apr 24 '24 04:04 Khady

I confirm, this is still the case with opam 2.2

kit-ty-kate avatar May 02 '24 14:05 kit-ty-kate

Are you importing in a switch that already exist ?

rjbou avatar May 06 '24 10:05 rjbou

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.

kit-ty-kate avatar May 06 '24 10:05 kit-ty-kate

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.

rjbou avatar May 06 '24 12:05 rjbou

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

Khady avatar May 06 '24 17:05 Khady

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

kit-ty-kate avatar May 06 '24 17:05 kit-ty-kate