-
Notifications
You must be signed in to change notification settings - Fork 390
behaviour when moving local switches around #3411
Description
Issues arise when one has a local switch and e.g. renames its parent directory, e.g. foo/_opam becomes bar/_opam. It's difficult to handle, and in any case the OCaml ecosystemdoesn't perfectly handle relocation just yet, but we can probably do better (esp. when the shell hook in is place).
-
_opam/.opam-switch/environmentbecomes wrong which leads toopam envmalfunctionning. For this we should add a check thatOPAM_SWITCH_PREFIXmatches. First opam reads$OPAM_SWITCH_PREFIX/.opam-switch/environmentand reverts it (here it can't be found) ; then it reads<current-switch-prefix>/.opam-switch/environmentand applies it (here it's found but obsolete). This leads toopam envinfinitely adding to e.g.PATH... FixingOPAM_SWITCH_PREFIXwould avoid that, but still not load a correct environment: the file should actually be re-generated, but that's not allowed from the shell hook (read-only mode), so maybe just bail out in that case ? -
the switch has registered in
~/.opam/configwon't be correct anymore, but that should already be handled fine by the next opam calls (removed and added switches (once used) are detected and automatically updated)
Thanks to @samoht for reporting the original issue to me