forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Description
Note: This issue only repros when the Python Environments extension is enabled in VS Code.
Repro Steps:
- open a workspace in VS Code and create a new Python file, make sure the Python Environments extension is enabled.
- set a global Python interpreter as the active environment.
- click the
Select Python Interpreterbutton on the bottom right corner and switch to a different conda env or venv. - notice the active environment does update in the UI. However, Pylance still considers the previous environment as the active one.
Investigation I did:
- On the Pylance side, we listen for the
pythonEnvironmentApi.onDidChangeEnvironmentevent and send a custom LSP notification when the event fires. - When the Pylance server receives this LSP notification, it sends a
workspace/configurationrequest. - The response is intercepted in the middleware, where we call
pythonApi!.environments!.getActiveEnvironmentPath(uri)andpythonApi!.environments!.resolveEnvironment(activePath)to get the active Python path. - The middleware then modifies the response like
pythonPathand returns it to the server.
I noticed that the env path returned in Step 3 from the python api does not always return the newly selected environment, especially when switching from a global interpreter to a conda one or a workspace venv.
@karthiknadig, do you have any insights on what might be causing this behavior in the Python API?
Metadata
Metadata
Assignees
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team