You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#14694. Adds a python.getEnvironmentHealth command that produces a JSON report on whether the current Python setup is ready to start a session, following Positron's recommendations. The command runs four checks in dependency order and short-circuits (marking later items skipped) when an earlier one fails:
discovery - Positron can discover Python environments (the PET locator is operational).
pythonInstalled - a supported Python (3.9-3.14) is installed.
dedicatedEnvironment - a dedicated (workspace-local or named) virtual environment is available.
environmentReady - the would-be interpreter resolves and runs, its version is supported, its Jupyter kernel (ipykernel) is usable, and (on Apple silicon) it is not an x64 build running under Rosetta.
Each item returns a pass / warn / fail / skipped status, a localized summary and detail, and an optional fix (a command id, JSON-safe args, and a button label) that a frontend can invoke to resolve the problem. The full result is logged as JSON to the Python output channel.
There is no UI yet; this PR is the backend groundwork. The command doubles as a developer probe run from the Command Palette ("Python: Print environment health report to Output"). A frontend to surface the report will come in a follow-up.
Supporting changes:
NativePythonFinder now tracks lastDiscoveryError so the discovery check can tell a broken locator apart from an empty one; it is set on process/connection/refresh errors and cleared on a successful refresh.
python.createEnvironmentAndRegister now accepts a URI-string workspaceFolder (new CreateEnvironmentAndRegisterOptions) so a health-check fix can pass it across the command boundary; it rehydrates the string to a WorkspaceFolder internally.
isBaseCondaEnvironment is exported from environmentTypeComparer for reuse.
Release Notes
New Features
N/A
Bug Fixes
N/A
Developer-facing groundwork; no user-visible feature yet. The palette command only logs a diagnostic report to the Output panel.
Validation Steps
@:interpreter
This command has no dedicated e2e coverage yet (no UI). The logic is covered by unit tests; run them from extensions/positron-python:
npm run test:unittests -- --grep "Python Environment Health"
npm run test:unittests -- --grep "Positron Create Environment APIs"
Manual smoke test via the Command Palette ("Python: Print environment health report to Output"), confirming the Python output channel shows the JSON report and ok reflects the state:
No folder open, with a dedicated env discovered elsewhere -> dedicatedEnvironment warns. Open a folder that uses a venv -> all items pass, ok: true.
Folder open using a global/system/base interpreter -> dedicatedEnvironment fails with a "Create Python Environment" fix.
Folder open using a workspace venv on a supported Python -> all items pass.
(Apple silicon) Interpreter is an x64 build -> environmentReady warns about Rosetta with an "Install Native Python" fix.
Set python.allowUvPythonInstall to false and confirm the install-Python fixes are omitted (discovery/install checks still run).
Sorry, please hold. I want to look into a bit of weirdness where I have a workspace open without a venv and the health check was completely green, pointing to a global python.
I have a workspace open without a venv and the health check was completely green, pointing to a global python
This is because my global python was classified as uv and this PR doesn't handle distinguishing the base uv Pythons from venv uv Pythons. Instead of adding logic to handle that here, I think it makes more sense to classify base uv Pythons as Global: #14912
(We've already received feedback that this would make more sense.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14694. Adds a
python.getEnvironmentHealthcommand that produces a JSON report on whether the current Python setup is ready to start a session, following Positron's recommendations. The command runs four checks in dependency order and short-circuits (marking later itemsskipped) when an earlier one fails:Each item returns a
pass/warn/fail/skippedstatus, a localized summary and detail, and an optional fix (a command id, JSON-safe args, and a button label) that a frontend can invoke to resolve the problem. The full result is logged as JSON to the Python output channel.There is no UI yet; this PR is the backend groundwork. The command doubles as a developer probe run from the Command Palette ("Python: Print environment health report to Output"). A frontend to surface the report will come in a follow-up.
Supporting changes:
NativePythonFindernow trackslastDiscoveryErrorso the discovery check can tell a broken locator apart from an empty one; it is set on process/connection/refresh errors and cleared on a successful refresh.python.createEnvironmentAndRegisternow accepts a URI-stringworkspaceFolder(newCreateEnvironmentAndRegisterOptions) so a health-check fix can pass it across the command boundary; it rehydrates the string to aWorkspaceFolderinternally.isBaseCondaEnvironmentis exported fromenvironmentTypeComparerfor reuse.Release Notes
New Features
Bug Fixes
Developer-facing groundwork; no user-visible feature yet. The palette command only logs a diagnostic report to the Output panel.
Validation Steps
@:interpreter
This command has no dedicated e2e coverage yet (no UI). The logic is covered by unit tests; run them from
extensions/positron-python:Manual smoke test via the Command Palette ("Python: Print environment health report to Output"), confirming the Python output channel shows the JSON report and
okreflects the state:dedicatedEnvironmentwarns. Open a folder that uses a venv -> all items pass,ok: true.dedicatedEnvironmentfails with a "Create Python Environment" fix.environmentReadywarns about Rosetta with an "Install Native Python" fix.python.allowUvPythonInstalltofalseand confirm the install-Python fixes are omitted (discovery/install checks still run).