-
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
local switches: shortcut for eval in older project #3143
Comments
Just Also, |
Oh! I was going by the guidelines that opam gives you when creating a new local switch. I suspect what's going on is that I have multiple local switches, and I am changing directory between them. At this point, Perhaps |
I think the latter could be even more confusing in other cases. But I guess the source of your confusion here boils down to this:
Here the current switch is inferred from CWD, hence opam doesn't set the
Here the switch is set explicitely, and opam doesn't actually check that it could have been inferred. Consequently, it sets the So the two, in their current implementation, are slightly different. You would have been safe from the current problem using the first one, but basically:
It's clearly a bit too subtle. A first thing would be to have Any better CLI ideas ? Maybe you're right and we can't have |
@dbuenzli, you generally are of good advice regarding such interface concerns. Do you have an opinion on this ? |
So after an hour and half of head scratching I think I no longer understand the issue: why is If we look at the problem from a standard cli ui perspective, environment variables are simply a mean for the end-user to override a value for a cli option value. In our case this is the default value for the option What is odd is that by doing:
I get the environment for I would argue that this is not what There are enough other ways of specifying the default switch to operate on, intra ( If you stop doing so the semantics becomes clear, in any environment we get:
and that's all. |
@dbuenzli: thanks a lot for helping with this :). Indeed, we try to do two things at the same time, which intersect, but are quite different. The fact that there is some magic involved in deciding whether we do one of the two doesn't help. One side-note: we speak about The original, well-intentioned purpose was to provide "shell specific" selection of a switch¹ (so both for opam and the environment). But we got tempted by the unusual fact that we could actually change the environment in this case. And local switches made the problem more apparent. Now, while I want to fix this (maybe providing an option ¹ This raises another question: should |
note: that won't help much in script, but running |
Maybe not directly but via a script that invokes
I think Another option to ponder, also w.r.t. our discussion in #3181 (comment) would be a |
(Oh and since I'm there for |
I think it is a good idea to remove the heuristic used in |
On 24 Jan 2018, at 00:48, Louis Gesbert ***@***.***> wrote:
¹ This raises another question: should opam exec set OPAMSWITCH, or stay similar to opam env ? Nobody would do opam exec --switch foo -- opam bla anyway would they ?
I do `opam exec --sw=foo -- opam upgrade` to upgrade in background while working in another switch bar. But I guess it's not a very good behavior.
|
@Khady Simply doing |
@Khady Simply doing opam upgrade --sw=foo doesn't work ?
I was not aware of this option. Thanks!
|
Right now, I shell alias this for whenever I switch back to building a project with a local switch:
It would be nice to have a shortcut for this, or some other recommendation for how to use it more seamlessly.
opam exec bash
works fine as well, but obviously requires a subshell.The text was updated successfully, but these errors were encountered: