Skip to content

Startup selection stays on a fallback environment when the configured defaultEnvManager registers late #1997

Open

Description

Written with Claude Code (AI-assisted) and reviewed by me.

Environment data

Repro Steps

  1. Install an extension that contributes an environment manager through registerEnvironmentManager, e.g. Pixi Code (renan-r-santos.pixi-code), and open a project it manages.
  2. Set "python-envs.defaultEnvManager": "renan-r-santos.pixi-code:pixi". In my case python.defaultInterpreterPath also points to a Miniconda interpreter.
  3. Reload the window.

Expected behavior

The workspace ends up on the configured manager's environment (here LearningMLDL:default).

Actual behavior

The priority chain runs before the third-party manager has registered (its extension only activates after this extension returns its API), so selection falls back to python.defaultInterpreterPath. Since #1533 the warning is correctly suppressed, but the selection itself is never re-evaluated once the manager registers, so the workspace stays on the fallback (base) until the user picks the environment again.

Logs

Released 1.42.0 (timestamps from one reload):

12:09:30.779 [interpreterSelection] Applying initial environment selection for 1 workspace folder(s)
12:09:30.779 [warning] [priorityChain] d:\Projects\LearningMLDL defaultEnvManager 'renan-r-santos.pixi-code:pixi' not found, trying next priority
12:09:30.861 Extension for manager renan-r-santos.pixi-code:pixi is not active: Activating...
12:09:31.073 Extension for manager renan-r-santos.pixi-code:pixi is now active.
12:09:32.915 [interpreterSelection] LearningMLDL: base (3.13.5) (source: defaultInterpreterPath)

The manager is checked about 80 ms before its extension even starts activating, so this can't be fixed on the contributing extension's side: any extension that depends on ms-python.vscode-python-envs activates only after the check has already run.

In this run the Pixi extension later restored its own saved selection, which happened to correct things. In another run with the same setup, the in-flight startup selection overwrote that correction:

12:32:56.728 Changed environment from undefined to LearningMLDL:default (3.15.2) for: d:\Projects\LearningMLDL
12:32:57.165 Changed environment from LearningMLDL:default (3.15.2) to base (3.13.5) for: d:\Projects\LearningMLDL
12:32:57.167 [interpreterSelection] LearningMLDL: base (3.13.5) (source: defaultInterpreterPath)

Additional context

I have a PR ready implementing this, with unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions