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

opam 2.2.0~alpha2: OPAMSWITCH does not work anymore #5696

Closed
eponier opened this issue Oct 10, 2023 · 3 comments · Fixed by #5743
Closed

opam 2.2.0~alpha2: OPAMSWITCH does not work anymore #5696

eponier opened this issue Oct 10, 2023 · 3 comments · Fixed by #5743

Comments

@eponier
Copy link

eponier commented Oct 10, 2023

The reason is that the shell hook resets OPAMSWITCH to the empty string as soon as it is set. This is because opam env --shell=zsh --readonly (my shell is zsh) prints OPAMSWITCH=''; export OPAMSWITCH; as the first line.

Before, the same command did not print OPAMSWITCH. This seems to be a consequence of #5417.

@kit-ty-kate
Copy link
Member

I’m personally unable to reproduce this locally with 2.2.0~alpha2. Could you show a reproducible test case if you can?

@eponier
Copy link
Author

eponier commented Oct 17, 2023

I turned off the shell hook to experiment. By default, opam env --shell=zsh --readonly 2> /dev/null <&- does not mention OPAMSWITCH. But if I type eval $(opam env --set-switch --switch switch2) (while global switch is switch1), opam env --shell=zsh --readonly 2> /dev/null <&- contains as the first line OPAMSWITCH=''; export OPAMSWITCH;.
If I just set OPAMSWITCH manually, this does not happen (but then I have an unsynchronized environment, and, strangely, this not not reported by opam).

@kit-ty-kate
Copy link
Member

Mmh, indeed i can reproduce. Thanks for the report and the test-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants