Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

behaviour when moving local switches around #3411

Open
AltGr opened this issue Jun 15, 2018 · 0 comments
Open

behaviour when moving local switches around #3411

AltGr opened this issue Jun 15, 2018 · 0 comments

Comments

@AltGr
Copy link
Member

AltGr commented Jun 15, 2018

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/environment becomes wrong which leads to opam env malfunctionning. For this we should add a check that OPAM_SWITCH_PREFIX matches. First opam reads $OPAM_SWITCH_PREFIX/.opam-switch/environment and reverts it (here it can't be found) ; then it reads <current-switch-prefix>/.opam-switch/environment and applies it (here it's found but obsolete). This leads to opam env infinitely adding to e.g. PATH... Fixing OPAM_SWITCH_PREFIX would 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/config won'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

AltGr added a commit to OCamlPro/opam that referenced this issue Jun 15, 2018
even if the files have been moved / the switch renamed.

This is not a complete fix to ocaml#3411 (doesn't add a warning, and the PATH
will only become correct once a package operation has been done), but
avoids the pathological cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant