Clarification for updateActiveEnvironmentPath
documentation
#25488
Replies: 3 comments 1 reply
-
I also noticed that when selecting an interpreter, the extension seems to cache it, and the next time I open the same workspace, the cached environment is loaded. Is there a way to enter an interpreter without having it cached? In my case, I’m writing an extension that automatically enters the environment when the active editor changes to a PEP 723–compatible script, but I don’t want it to be associated with the environment. @eleanorjboyd Sorry for the ping—do you have any ideas? |
Beta Was this translation helpful? Give feedback.
-
Hi! Both of these are great questions / items. For Secondly with PEP 723 we are looking into making it so a new environment is created on script run and cleaned up (not sure what timeframe for cleanup but would think that editor load it would redo but unsure). Is this the type of thing you are thinking of and would want? |
Beta Was this translation helpful? Give feedback.
-
@eleanorjboyd Thank you for the explanation — that helps a lot 🙏
Am I right that this is a new separate extension for handling virtual environments? I’d actually like to fully support the legacy environment handling via the Python extension (since most users already have it installed), and then add support for other extensions that handle virtual environments as well.
I already have a working example of my extension. What it does is simply react to active text editor changes: if the new file is a PEP 723–compatible file, it uses uv to switch to that script’s environment (so things like cleanup and environment creation are handled by uv).
What I most want an answer for is whether there’s a way to switch to the environment without “caching” it, so that when I reopen the same workspace later it doesn’t load the cached environment. I need this because when my extension switches to a script environment and the user closes VS Code, the next time they open it, VS Code loads the environment of the PEP 723–compatible script — which is not the expected behavior. It should instead load the default project environment for that workspace. Just to be clear, I thought the resource argument might be able to solve that problem, but to be honest, I still don’t fully understand what it does. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It's not clear to me what the
resource
parameter ofextension.environments.updateActiveEnvironmentPath
does exactly. Could the documentation be clarified? I’d be happy to open a pull request if needed.It's documented as
File or workspace to scope to a particular workspace folder.
What does it mean to scope a file to a particular workspace folder? Does it mean the environment can be set only for that file within the workspace?
Beta Was this translation helpful? Give feedback.
All reactions