-
Notifications
You must be signed in to change notification settings - Fork 370
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
make --set-switch the default in opam env #3511
Comments
See #3143 for the discussion that led to this change. In short, it didn't play well with the automatic selection of switch based on I agree that possibly having a desynchronisation between the environment as seen by opam (selected switch), and what is currently set in the environment can be annoying ; but, with local switches, setting The proper solution is to use the shell env-hooks ( |
Forgot to say, thanks for the feedback! |
@AltGr While I understand your point on a fundamental level, the resulting UI is really terrible. I think many people agree that using local switches, either per-directory or per-terminal, is one of the best workflow for using OPAM. I really think the UI should be optimized for that worflow and discourage changing the global switch, which often causes users to have desynchronized envs. I don't have a concrete advice for crafting a UI that empowers this workflow, but piling additional arguments on operations as fundamental as "Please give me this switch in this terminal" is not great. |
@Drup: but the preferred way is to enable the shell hook, which completely makes the issue go away? |
The shell hook is for per-directory switches, but not per-terminal, which are also very useful. |
@Drup: you just need |
@AltGr This is not documented and highly non obvious. |
Agreed on the lack of documentation. The only hint is that
but that might go unnoticed, and if the shell hooks have been set, it would be a no-op, so that should in fact be an error. Or magically understood and fixed by opam... As for exporting a variable, I would argue that, if made clear enough, I would be very interested in better solutions to this if you have suggestions. As mentionned in the issue I linked, FWIW in my personal habits I have mostly replaced it with the shell hook + path-based switch selection, with local switches or links (using I'll keep searching for a solution that works well with local switches and provides a clear interface for shell-based switch selection, whether you are already used to |
@AltGr I think we should just try to have a comprehensive "workflow" document that describes what is the preferred opam workflow for working with switchs. Having one would probably make us realize how awkward many of the commands are for this preferred workflow and make everything be more consistent. I agree that the workflow with For instance, |
@Drup wants me to report bad experience that I noticed while using opam2, so here is the first issue. Please let me now if it should be done another way.
I think that
--set-switch
should be enabled by default when usingopam env
. My experience is thatopam switch set
is pretty confusing and should actually be totally avoided. Instead of using it, one should only rely oneval $(opam env --set-switch)
. It would ensure that the state is per shell rather than global. And the experience would be close to what exist in python.From discussions on IRC, it seems that even experienced user like @c-cube and @Armael were not aware of
--set-switch
.The text was updated successfully, but these errors were encountered: