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
[bug] venv modified vars do not take into account other venvs #8453
Comments
First, which version do you use? venvs were changed several times and such behavior was (or at least tried) to be fixed. Another thing, activating multiple envs is still prone to errors if you don't deactivate them strictly in reverse order. That said, deactivating environment is anyways a big issue (especially when there are multiple ones) so the best way is to activate in another shell... |
Updated my original post! The issue is that the venvs might introduce the same env var, such as Env:\DYLD_LIBRARY_PATH. These will now conflict as both venvs assume that this variable is new instead of being modified. I think this can be fixed by moving this detection to time of activation of the venv instead of generation. I'm willing to give it a go to fix this, but I want to see if someone sees something off with this as I don't want to put time in a PR that will strand :-). A (hacky) easy fix would be treating everything as modified instead of new. |
Now I see...
This is actually how it is. As I understand the issue is that all generators (re)use the same name for "old" variable, so when you activate nested environment the "old" variable gets overwritten. The workaround would be to "scope" "old" variables with generator name, i.e. use not At least you'll get better deactivation if you deactivate them in the reverse order. However there are discussions to introduce a conan command to run a command inside environment (like |
Have you checked this? #8426 I am working on it, the idea is that the "activate" script is the one capturing the state to be restored, dynamically. I think this is the behavior that is expected, isn't it? The plan is to make the new environment the main model for the new toolchains approach. |
@ytimenkov looking at the code it seems like modified/new is detected at generation time not run? (for example conan/conans/client/envvars/environment.py Line 171 in 3694324
@memsharded ah yes exactly, looks good. Please don't forget powershell :). Any clue when this might go in? If it is in months a less nice fix in the current setup could also help. |
Ah, right, looking at evolution of virtualenvs code I assumed that it just stores all variables as in my initial attempt to fix it (#4248). Got confused by reading from |
@memsharded #8534 is in, but does not fix this issue. Say that activate and activate_run both modify LD_LIBRARY_PATH deactivating both of them will give an error as both the deactivate scripts will try to remove LD_LIBRARY_PATH from your environment. |
Excuse me I need to use the new generators. |
Environment Details (include every applicable attribute)
If you use multiple venv (such as activate & activate_run) at the same time errors might occur. When generating the venv files conan checks which env vars exists and treats those differently than new variables it will create when activating a venv.
When you activate two venv this assumption does not necessarily hold true, as a var might be new for activate, but when doing activate_run it is modified.
We could move the detection of new vs existing to the venv script itself. This way it does not matter when the venv scripts are generated and when they are run.
The text was updated successfully, but these errors were encountered: