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

last-env files should be stored outside the switch #5823

Closed
dra27 opened this issue Feb 6, 2024 · 0 comments · Fixed by #5962
Closed

last-env files should be stored outside the switch #5823

dra27 opened this issue Feb 6, 2024 · 0 comments · Fixed by #5962
Assignees
Milestone

Comments

@dra27
Copy link
Member

dra27 commented Feb 6, 2024

The original implementation of #5417 addressed two problems:

The first problem is solved and working correcting in that the last-env file contains the environment updates which were previously applied to the environment. Previously, opam always used the same environment file both to revert and apply updates, which was what resulted in the effective prohibition of packages using setenv (because after uninstalling a package which had setenv instructions, environment no longer contains the changes from that package, so they can't be reverted).

The second part was solved in the original version of the PR by proposing that the last-env files be stored in /tmp, but we changed this prior to merge. Unfortunately, the change at present breaks/removes the second part of the fix.

The last-env files must at least be stored outside the switch, or the removal of a global switch or removal/moving of a local switch causes the same problem (the fact that moving a local switch probably breaks the switch is not important here - it's still important to be able to revert the old environment). This becomes a serious concern for the MSVC compiler packages, which contain a large number of environment updates.

There are two choices:

  1. As in the original, put the last-env files in /tmp (or equivalent)
  • This means that one can delete the opam root and still successfully revert previous environment updates
  • At first glance, that seems utterly niche (not sure anyone beyond opam devs operates with multiple opam roots), but it also hardens the case of rm -rf ~/.opam && opam init which is a more common user "fix" than we wish it was
  1. Put the last-env files in ~/.opam/.last-env

I'm still kinda keen on 1, perhaps with a fallback to 2 if, for some reason, TMPDIR is not writeable, but the Windows implications mean I think we must do at least 2.

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

Successfully merging a pull request may close this issue.

3 participants