Skip to content

Audit and potentially deprecate defaultInterpreterPath updates when Python Environments extension is active #25735

@eleanorjboyd

Description

@eleanorjboyd

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)

  1. VirtualEnvironmentPrompt: When a new virtual environment is detected in the workspace
  2. ActivatedEnvironmentLaunch: When VS Code is launched from a terminal with an activated conda/venv environment
  3. Create Environment command: After using the "Create Environment" command
  4. Extension APIs: When other extensions call updateActiveEnvironmentPath() or setActiveEnvironment()

Further investigation is needed to understand the full impact on prompting behavior and auto-selection.

Questions

  1. Do we want the Python extension to be able to edit defaultInterpreterPath when the Python Environments extension is active?
  2. Does the Python Environments extension handle all the scenarios listed above?

Metadata

Metadata

Assignees

Labels

area-environmentsFeatures relating to handling interpreter environmentsneeds spikeLabel for issues that need investigation before they can be worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions