Skip to content

Bug: Command 'python.getRecommendedEnvironment' already exists in multi-root workspace #25516

@ameicler

Description

@ameicler

Type: Bug

Behaviour

The Python extension fails to activate properly in multi-root workspaces, throwing a command registration error: command 'python.getRecommendedEnvironment' already exists. The error occurs during workspace activation but doesn't prevent core functionality from working.

Steps to reproduce:

  1. Create a minimal multi-root workspace structure:
mkdir -p /tmp/test-bug/{project-a,project-b}
cd /tmp/test-bug
python -m venv project-a/.venv
python -m venv project-b/.venv
  1. Create a workspace file test-bug.code-workspace:
{
    "folders": [
        {
            "path": "project-a",
            "settings": {
                "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
            }
        },
        {
            "path": "project-b",
            "settings": {
                "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
            }
        }
    ]
}
  1. Open the workspace in VS Code:
    code /tmp/test-bug/test-bug.code-workspace

  2. Open the Output panel (View→Output) and select "Python" from the dropdown

  3. Observe the command registration error in the logs when switching context betwen files of different workspaces

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2025-10-09 10:53:13.414 [info] > pyenv which python
2025-10-09 10:53:13.414 [info] cwd: /tmp/python-bug-repro/project-b
2025-10-09 10:53:13.422 [error] [
  'Failed to activate a workspace, Class name = v, completed in 88ms, has a falsy return value, Arg 1: <Uri:/tmp/python-bug-repro/project-b/main.py>, Return Value: undefined',
  [Error: command 'python.getRecommendedEnvironment' already exists
  	at Kb.registerCommand (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:112:40259)
  	at Object.registerCommand (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:199:102897)
  	at d.activate (/Users/antoine.meicler/.vscode/extensions/ms-python.python-2025.14.0-darwin-arm64/out/client/extension.js:2:530888)
  	at /Users/antoine.meicler/.vscode/extensions/ms-python.python-2025.14.0-darwin-arm64/out/client/extension.js:2:2457
  	at Array.map (<anonymous>)
  	at v.activateWorkspace (/Users/antoine.meicler/.vscode/extensions/ms-python.python-2025.14.0-darwin-arm64/out/client/extension.js:2:2447)]
]

Installed Extensions
Extension Name Extension Id Version
python ms- 2025.14.0
vscode-pylance ms- 2025.8.3
System Info
Item Value
CPUs Apple M4 Pro (12 x 2400)
GPU Status 2d_canvas: enabled
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: enabled_on
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 3, 4, 4
Memory (System) 48.00GB (0.83GB free)
Process Argv
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions