Skip to content

Extension breaks uv venv interpreter detection in dev containers #1266

@galshi

Description

@galshi

After rebuilding my dev container today vscode stopped finding my uv-created venv interpreter. Uninstalling/disabling this extension immediately fixes it, reproduced multiple times across fresh no-cache rebuilds.

This extension gets pulled in as part of ms-python.python, so it was already installed without me explicitly adding it.

Setup

devcontainer.json (simplified):

{
  "image": "mcr.microsoft.com/devcontainers/python:3.14",
  "features": {
    "ghcr.io/devcontainers-extra/features/uv:1": {}
  },
  "postCreateCommand": "uv sync --extra dev",
  "customizations": {
    "vscode": {
      "extensions": ["ms-python.python"]
    }
  }
}

pyproject.toml (simplified):

[project]
requires-python = ">=3.14"

[project.optional-dependencies]
dev = [
    "ruff",
    "pylint",
    "pylint-pydantic",
    "pre-commit",
    "cfn-lint",
]

[tool.setuptools]
package-dir = { "" = "." }

[tool.uv]
python-preference = "system"

Venv is created by uv sync at .venv/ at the repo root. Both of these interpreter path settings fail (workspace settings under .vscode/settings.json):

"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
"python.defaultInterpreterPath": ".venv/bin/python"

Reproduce

Can't give a minimal repro since this is a cut-down version of my actual setup, but roughly:

  1. Build the devcontainer above (with this extension installed via ms-python.python)
  2. Open VS Code, interpreter at .venv/bin/python isn't found
  3. Uninstall/disable this extension and reload the window, interpreter works fine

Potential root cause

uv symlinks the Python binary inside the venv instead of copying it, see astral-sh/uv#2103 and astral-sh/uv#6782. This extension might not be resolving those symlinks correctly, causing detection to silently fail. The old ms-python.python worked fine on my previous devcontainer rebuild a week or two ago, so this extension seems to be the regression. Possibly related to microsoft/vscode-python#14592 as well.

Workaround

Set "python.useEnvironmentsExtension": false in .vscode/settings.json:

// Make VS Code use the uv-created venv
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
// This extension breaks the above setting
"python.useEnvironmentsExtension": false,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions