Skip to content

fix: use run.executable for interpreter identification instead of activatedRun.executable#949

Open
renan-r-santos wants to merge 1 commit intomicrosoft:mainfrom
renan-r-santos:use-run-executable-for-interpreter-identification
Open

fix: use run.executable for interpreter identification instead of activatedRun.executable#949
renan-r-santos wants to merge 1 commit intomicrosoft:mainfrom
renan-r-santos:use-run-executable-for-interpreter-identification

Conversation

@renan-r-santos
Copy link

Fixes microsoft/vscode-python-environments#987

Hi @eleanorjboyd. I saw you merged test discovery 2.0 and was very excited to test it. I still have environment activation issues after that PR was merged, so I decided to investigate it a bit further. I'd appreciate it if you could review this PR.

The debugger reads activatedRun.executable in three places to figure out which Python binary to use. This works today because every environment manager happens to set activatedRun.executable to the actual Python path, but it breaks when a manager sets it to a wrapper command (like pixi run ... python or how conda used to do conda run ... python before microsoft/vscode-python-environments#860).

I believe the three call sites (getInterpreterDetails, getSettingsPythonPath, getExecutableCommand) aren't running Python, they're identifying the interpreter for things like resolveEnvironment() and spawning the debug adapter. And I think that's what run.executable is for. activatedRun is for execution contexts like runInBackground in vscode-python-environments.

The change should be backwards compatible since run.executable and activatedRun.executable are currently the same value for all existing managers (venv, system, conda). It only matters when they differ, which is the case for pixi-code (see microsoft/vscode-python-environments#987 and #872).

Debuggee activation is not affected, that still goes through getActivatedEnvironmentVariables() and terminal envVarCollection.

This unblocks environment managers from setting activatedRun to a wrapper command like pixi run ... python, which is needed to fix pytest discovery not activating the environment (microsoft/vscode-python-environments#987). Right now runInBackground (used by test discovery) relies on activatedRun for execution, but managers can't set it to anything other than the bare Python path without breaking the debugger.

…reter identification

getInterpreterDetails, getSettingsPythonPath, and getExecutableCommand need
the actual Python binary path, not the activated run command. Using
activatedRun.executable breaks when environment managers set it to a wrapper
command (e.g. pixi run ... python).

This unblocks managers like conda and pixi from using wrapper commands in activatedRun without
breaking the debugger, while remaining backwards-compatible since the two
values are currently identical for all existing managers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VSCode Python test discovery not activating the environment

1 participant