-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Summary
The Python extension currently updates the python.defaultInterpreterPath setting in multiple places throughout the codebase. When the Python Environments extension is installed and active (python.useEnvironmentsExtension: true), this creates potential conflicts and unexpected behavior since the Python Environments extension is intended to manage interpreter/environment selection independently.
Current Code Paths That Update defaultInterpreterPath
| Code Path | File | Purpose |
|---|---|---|
InterpreterPathService.update() |
src/client/common/interpreterPathService.ts#L107 | Central method for updating the setting |
deprecatedProposedApi.setActiveEnvironment() |
src/client/deprecatedProposedApi.ts#L135 | API for other extensions to set the active environment |
environmentApi.updateActiveEnvironmentPath() |
src/client/environmentApi.ts#L280 | Public API for extensions |
VirtualEnvironmentPrompt |
src/client/interpreter/virtualEnvs/virtualEnvPrompt.ts#L78 | Prompts user when a new virtual environment is detected |
ActivatedEnvironmentLaunch |
src/client/interpreter/virtualEnvs/activatedEnvLaunch.ts#L119 | Auto-selects interpreter when VS Code is launched from an activated environment |
createEnvApi |
src/client/pythonEnvironments/creation/createEnvApi.ts#L123 | Updates path after "Create Environment" command |
None of these code paths are currently guarded by useEnvExtension() to check if the Python Environments extension is active.
Deprecation Considerations
If we disable these updates when the Python Environments extension is active, defaultInterpreterPath would no longer be updated by the Python extension in the following scenarios (as these are the situations where it is updated for now)
- VirtualEnvironmentPrompt: When a new virtual environment is detected in the workspace
- ActivatedEnvironmentLaunch: When VS Code is launched from a terminal with an activated conda/venv environment
- Create Environment command: After using the "Create Environment" command
- Extension APIs: When other extensions call
updateActiveEnvironmentPath()orsetActiveEnvironment()
Further investigation is needed to understand the full impact on prompting behavior and auto-selection.
Questions
- Do we want the Python extension to be able to edit
defaultInterpreterPathwhen the Python Environments extension is active? - Does the Python Environments extension handle all the scenarios listed above?