Skip to content

Python activation fails when environment extension settings conflict across scopes #26068

Description

@atomiechen

Behaviour

The Python extension fails to activate when python.useEnvironmentsExtension is false in user settings and true in workspace settings.

Steps to reproduce

  1. Start VS Code with empty --user-data-dir and --extensions-dir directories.

  2. Install only the latest stable Python Environments extension, Pylance, and Python extension.

  3. Add this user setting:

    {
        "python.useEnvironmentsExtension": false
    }
  4. Open a folder with this workspace setting:

    {
        "python.useEnvironmentsExtension": true
    }
  5. Open a Python file.

Expected behaviour

The Python extension activates without an exception. If the Python Environments extension declines activation, the Python extension uses its legacy environment path.

This follows the current cross-extension contract: any explicit false disables the Python Environments extension window-wide. This issue concerns inconsistent activation checks, not configuration-scope precedence.

Actual behaviour

The effective workspace value makes useEnvExtension() return true, but the Python Environments extension declines activation because it finds an explicit false at user scope and exports no API. getEnvExtApi() then dereferences the undefined export:

Activating extension ms-python.python failed
TypeError: Cannot read properties of undefined (reading 'onDidChangeEnvironment')
    at .../ms-python.python-2026.4.0-darwin-arm64/dist/extension.js

shouldEnvExtHandleActivation() already mirrors the Python Environments extension's explicit-disable rules, but useEnvExtension() only checks the effective configuration value.

Environment

  • VS Code: 1.130.0
  • Python extension: 2026.4.0 (Marketplace stable); also reproduced from current main at 757def8f844b2241f041c1d74435740fa621a8c5
  • Python Environments extension: 1.36.0
  • Pylance: 2026.3.1
  • OS: macOS 15.3.2 arm64
  • Workspace: single-folder

Isolated verification

  • Stable extensions + conflicting settings: reproduces the exception.
  • Patched Python VSIX + the same settings: activates and uses the legacy locator.
  • Stable extensions + the user-level false removed: Python Environments starts and discovers backend/.venv.

AI disclosure: Prepared with assistance from OpenAI Codex.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions