Skip to content

Fix Pixi kernel activation for System/Unknown interpreters - #26198

Merged
Stella Huang (StellaHuang95) merged 1 commit into
microsoft:mainfrom
StellaHuang95:fix-pixi-kernel-activation
Oct 5, 2026
Merged

Stella Huang (StellaHuang95) merged 1 commit into
microsoft:mainfrom
StellaHuang95:fix-pixi-kernel-activation

Conversation

@StellaHuang95

Copy link
Copy Markdown

Fixes microsoft/vscode-python-environments#1825.

Summary

The Python Environments extension can resolve a Pixi interpreter through its System fallback. This skips Python's type-gated pixi run path when collecting activation variables and falls through to an interactive pixi shell command. The collection can time out after 30 seconds, leaving Jupyter to launch an unactivated kernel and causing the reported Windows Matplotlib crash.

Use the existing non-interactive Pixi activation path for interpreters labeled System or Unknown when the resolver identifies their environment as Pixi. Harden the metadata-free resolver so a similarly nested, non-Pixi interpreter cannot be mistaken for a project environment.

Changes

  • Allow System and Unknown, alongside Pixi, to call the existing Pixi command resolver during background environment-variable collection. Preserve the existing fallback when no Pixi command is returned.
  • When prefix-local Pixi metadata is absent, require the interpreter's prefix to match an environment returned by pixi info --json, using the existing platform-aware path comparison. Use that matched environment's reported name rather than the directory basename.
  • Preserve metadata-based resolution, including interpreters outside the current workspace, and leave the Conda/venv activation branches, timeout values, and interactive terminal command builder unchanged.
  • Add regression coverage for mislabeled Pixi environments, default/named environments, paths with spaces, non-Pixi fallbacks, unmatched prefixes, and platform-dependent path comparison.

No Python Environments extension changes, new settings, or public API changes are required.

Validation

  • TypeScript compilation passed.
  • 252 targeted unit tests passed across the Pixi environment manager, activation service, terminal helper, and Python execution factory suites.
  • Production webpack and VSIX packaging succeeded; the extension bundle loaded for manual testing exactly matched the built VSIX.
  • Manually ran the reported plt.scatter() / plt.show() cell in the actual VS Code Interactive Window with Python Environments enabled. The plot rendered, and a follow-up cell executed on the same kernel.
  • Jupyter still reported the selected Pixi interpreter as Unknown; the Python output showed pixi run, and activation-variable collection completed in 863 ms. The follow-up cell confirmed the selected Pixi executable, PIXI_ENVIRONMENT_NAME=default, and the matching CONDA_PREFIX.
  • Switched the Interactive Window to regular system Python and a non-Pixi venv while the Pixi workspace remained open. Both executed successfully with the expected executable/prefix and without Pixi or Conda activation variables.

Manual setup: Windows x64, VS Code 1.139.0, Python Environments 1.39.0, Jupyter 2025.8.0, Pixi 0.76.1, Python 3.12.14, Matplotlib 3.11.2, and ipykernel 7.4.0.

Scope and review notes

This fixes background activation without treating the System label itself as evidence of Pixi ownership. The shared metadata-free resolver now also rejects unreported prefixes for its other callers.

The existing metadata route still trusts prefix-local Pixi metadata. Filesystem-alias resolution and malformed/stale metadata handling are outside this change.

The manual run used the fixed VSIX, not an unpatched-versus-patched UI comparison, and the extension versions are not all identical to the reporter's. Named Pixi environments and metadata-free detection cases are covered by unit tests rather than this UI walkthrough.

@StellaHuang95 Stella Huang (StellaHuang95) added the bug Issue identified by VS Code Team member as probable bug label Oct 5, 2026
Use non-interactive Pixi activation for mislabeled environments and require exact reported prefixes in the metadata-free resolver.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
auto-merge was automatically disabled October 5, 2026 22:54

Pull request was closed

@StellaHuang95
Stella Huang (StellaHuang95) merged commit d0d4ded into microsoft:main Oct 5, 2026
82 of 94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kernel crashed when plt.plot()

3 participants