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 layout upgrade from 2.2~alpha to 2.2~beta seems to delete empty switches #6049

Open Khady opened 1 week ago

Khady commented 1 week ago

I had a switch ahrefs-placeholder created with opam sw create ahrefs-placeholder --empty using an "old" alpha or beta of 2.2 (sorry I can't remember which version exactly). It was fine while using 2.2.0~beta2.

While running opam 2.2.0~rc1 for the first time, I had a warning telling me that my empty switch doesn't exist anymore

[WARNING] Removing global switch 'ahrefs-placeholder' as it no longer exists
This version of opam requires an update to the layout of /home/me/.opam from version 2.2~alpha to version 2.2~beta,
which can't be reverted.

The removal doesn't seem complete though, as if I try to create the switch again I get an error

opam sw create ahrefs-placeholder --empty || true
[ERROR] Directory "/home/me/.opam/ahrefs-placeholder" already exists, please choose a different name

This isn't a big problem as we have this empty repo for legacy reasons and creating it again is simple. But reporting anyway as it seems to be a weird behavior.

rjbou commented 1 week ago

Are you able to reproduce? I wasn't able to reproduce locally. Upgrade mechanism is supposed to remove only non well formed switches (missing switch-config file for global registered switches), so it shouldn't delete your empty switches (empty switches have a config file, it's just empty of packages). If you still have the issue, can you share the content of /home/me/.opam/ahrefs-placeholder and the /home/me/.opam/ahrefs-placeholder/.opam-switch/switch-config if present.