Skip to content

Python environment terminal activation breaks debugger launch #25192

Closed as not planned

Description

Type: Bug

Behaviour

Launching the python debugger (from a launch config or the button in the editor) when using "python.terminal.activateEnvironment": true and a Pixi environment does not work.
The debugger server is launched, but times out because the actual python command run in the terminal is flawed:

Image

As you can see, the command is prepended with the Pixi shell activation command and run as a whole.
The pixi shell ... command does not run code, it only activates the environment.
I believe the intended behavior is to prepent the pixi run ... command.

Steps to reproduce:

  1. Create a Pixi environment.
  2. Select the created environment using the "Python: Select Interpreter" command.
  3. Set the "python.terminal.activateEnvironment": true setting.
  4. Launch any python file for debugging.

Diagnostic data

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

2025-06-19 10:01:52.541 [info] Not enabling terminal env var experiment in multiroot remote workspaces
2025-06-19 10:01:52.544 [info] Send text to terminal: /home/pan/.pixi/bin/pixi shell --manifest-path /home/pan/repositories/Booster-AI/pixi.toml --environment booster-ai-development
2025-06-19 10:01:53.143 [info] Send text to terminal:  /usr/bin/env /home/pan/repositories/Booster-AI/.pixi/envs/booster-ai-development/bin/python /home/pan/.vscode-server/extensions/ms-python.debugpy-2025.8.0/bundled/libs/debugpy/adapter/../../debugpy/launcher 57177 -- -m deployment.scripts.build_and_push_docker_environment --environment civil_assistant_indexer --fetch-local-token --build-only --output-file ./_output/built_image.json 

Output for Python Debugger in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python Debugger)

2025-06-19 09:41:13.840 [info] Resolving launch configuration with substituted variables
2025-06-19 09:41:13.857 [info] DAP Server launched with command: /home/pan/repositories/Booster-AI/.pixi/envs/booster-ai-development/bin/python /home/pan/.vscode-server/extensions/ms-python.debugpy-2025.8.0/bundled/libs/debugpy/adapter
2025-06-19 09:41:13.959 [info] Received 'debugpySockets' event from debugpy.
2025-06-19 09:41:13.963 [info] Received 'debugpySockets' event from debugpy.
2025-06-19 09:41:13.963 [info] Received 'debugpySockets' event from debugpy.
2025-06-19 09:48:22.440 [info] Resolving launch configuration with substituted variables
2025-06-19 09:48:22.454 [info] DAP Server launched with command: /home/pan/repositories/Booster-AI/.pixi/envs/booster-ai-development/bin/python /home/pan/.vscode-server/extensions/ms-python.debugpy-2025.8.0/bundled/libs/debugpy/adapter
2025-06-19 09:48:22.599 [info] Received 'debugpySockets' event from debugpy.
2025-06-19 09:48:22.604 [info] Received 'debugpySockets' event from debugpy.
2025-06-19 09:48:22.605 [info] Received 'debugpySockets' event from debugpy.
2025-06-19 10:01:52.251 [info] Resolving launch configuration with substituted variables
2025-06-19 10:01:52.270 [info] DAP Server launched with command: /home/pan/repositories/Booster-AI/.pixi/envs/booster-ai-development/bin/python /home/pan/.vscode-server/extensions/ms-python.debugpy-2025.8.0/bundled/libs/debugpy/adapter
2025-06-19 10:01:52.470 [info] Received 'debugpySockets' event from debugpy.
2025-06-19 10:01:52.473 [info] Received 'debugpySockets' event from debugpy.
2025-06-19 10:01:52.475 [info] Received 'debugpySockets' event from debugpy.

Extension version: 2025.8.0
VS Code version: Code 1.101.0 (dfaf44141ea9deb3b4096f7cd6d24e00c147a4b1, 2025-06-11T15:00:50.123Z)
OS version: Windows_NT x64 10.0.26100
Modes:
Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.11
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Pixi
  • Value of the python.languageServer setting: Pylance
User Settings

Multiroot scenario, following user settings may not apply:

languageServer: "Pylance"

testing
• cwd: "<placeholder>"
• promptToConfigure: false
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"

experiments
• optInto: ["pythonTestAdapter"]
• optOutFrom: ["pythonTerminalEnvVarActivation"]

Installed Extensions
Extension Name Extension Id Version
azure-pipelines ms- 1.249.0
copilot Git 1.335.0
copilot-chat Git 0.28.0
datawrangler ms- 1.22.0
debugpy ms- 2025.8.0
docker doc 0.10.0
dotenv-vscode dot 0.28.1
even-better-toml tam 0.21.2
gitlens eam 17.2.0
indent-rainbow ode 8.3.1
js-debug ms- 1.100.1
jupyter ms- 2025.5.0
jupyter-renderers ms- 1.1.0
markdown-all-in-one yzh 3.6.3
markdown-preview-enhanced shd 0.8.18
python ms- 2025.8.0
resourcemonitor mut 1.0.7
ruff cha 2025.24.0
RunOnSave eme 0.2.7
shellcheck tim 0.37.7
tasks act 0.16.1
vscode-ai ms- 1.2.0
vscode-ai-remote ms- 1.4.2
vscode-auto-open-workspace zom 0.0.4
vscode-azureresourcegroups ms- 0.10.13
vscode-containers ms- 2.0.3
vscode-docker ms- 2.0.0
vscode-js-profile-table ms- 1.0.10
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-marimo mar 0.6.5
vscode-markdownlint Dav 0.60.0
vscode-pylance ms- 2025.6.1
vscode-yaml red 1.18.0
workspace-terminals jos 0.3.4
System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i7-13850HX (28 x 2304)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.66GB (9.34GB free)
Process Argv --crash-reporter-id bc453f47-6475-4dca-884b-395c4b2f80af
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu-24.04
OS Linux x64 6.6.87.2-microsoft-standard-WSL2
CPUs 13th Gen Intel(R) Core(TM) i7-13850HX (28 x 0)
Memory (System) 15.45GB (12.42GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vscaat:30438848
c4g48928:30535728
azure-dev_surveyonecf:30548226
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
e5gg6876:31282496
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
c7cif404:31314491
pythonpulldiagcf:31325931
996jf627:31283433
pythonrdcb7:31303018
usemplatestapi:31297334
0aa6g176:31307128
7bj51361:31289155
747dc170:31275177
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
he899328:31327032
useunpkg:31331645
1292j425:31329156
id45c886:31329544

Activity

  1. anthonykim1 commented on Jun 23, 2025

    @anthonykim1

    Hello Raphaël Melançon (@RaphaelMelanconAtBentley) Thanks for filing the issue.

    Does it get any better if you:

    1. Opt out of terminal env experiment via adding
      "python.experiments.optOutFrom": [
        "pythonTerminalEnvVarActivation"
      ],
    

    to your settings.json?

  2. RaphaelMelanconAtBentley commented on Jun 25, 2025

    @RaphaelMelanconAtBentley
    Author

    Hello @RaphaelMelanconAtBentley Thanks for filing the issue.

    Does it get any better if you:

    1. Opt out of terminal env experiment via adding
      "python.experiments.optOutFrom": [
        "pythonTerminalEnvVarActivation"
      ],
    

    to your settings.json?

    Nope, I get the exact same behavior as without it.

  3. RaphaelMelanconAtBentley commented on Jun 25, 2025

    @RaphaelMelanconAtBentley
    Author

    I'm on WSL, but I have multiple colleagues with the same issue on MacOS.

  4. RaphaelMelanconAtBentley commented on Jun 25, 2025

    @RaphaelMelanconAtBentley
    Author

    Here is a minimal repository that can reproduce this issue: https://github.com/RaphaelMelanconAtBentley/vscode-python-environment-activation-issue

  5. irm-codebase commented on Jun 30, 2025

    @irm-codebase

    I am likely seeing this same problem on Fedora 42.
    See here: microsoft/vscode-python-debugger#741

  6. RaphaelMelanconAtBentley commented on Jul 11, 2025

    @RaphaelMelanconAtBentley
    Author

    Any update on this issue Anthony Kim (@anthonykim1) ? This is limiting our entire development team at the moment...

  7. ignition5 commented on Jul 16, 2025

    @ignition5

    I have the same problem, the solution wanted!!!

  8. renan-r-santos commented on Jul 16, 2025

    @renan-r-santos

    This is also happening to me, but in a Linux devcontainer running on macOS. A few things I noticed:

    • It rarely happens on my machine, but some colleagues get this a lot more often, even though it is the same codebase. A few of them always hit this issue making debugging impossible.
    • After trying a few things and noticing it happens more often on a Mac M1 than a Mac M4, I got to reliably reproduce what I believe to be the same issue on my Mac M4 by adding a sleep 0.2 to my zsh init script.
    • I've opted into the pythonTerminalEnvVarActivation experiment, but it gets deactivated because I'm in a multi-root workspace.
    • If I open the project folder with the problematic launch.json as a single-root workspace, then pythonTerminalEnvVarActivation gets activated, and debugging the Pixi environments works just fine, even with a sleep 5 in my shell init script. It works on both Mac M4 and M1.

    Could this be related to #24589 (comment), particularly the timeout set here?
    If this is helpful and you'd like more info about my environment, please let me know.

  9. 12 remaining items

  10. anthonykim1 commented on Jan 8, 2026

    @anthonykim1

    I believe I am also encountering this issue. When I look at the python output screen I see an error:

    python-2025.12.0-darwin-arm64/python_files/printEnvVariables.py
    
    	at genericNodeError (node:internal/errors:983:15)
    	at wrappedFn (node:internal/errors:537:14)
    	at ChildProcess.exithandler (node:child_process:416:12)
    	at ChildProcess.emit (node:events:530:35)
    	at maybeClose (node:internal/child_process:1101:16)
    	at ChildProcess._handle.onexit (node:internal/child_process:304:5)] {
      code: null,
      killed: true,
      signal: 'SIGTERM',
      cmd: "/opt/homebrew/bin/pixi shell --manifest-path <my_manifest_path> && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /Users/<me>/.vscode/extensions/ms-python.python-2025.12.0-darwin-arm64/python_files/printEnvVariables.py"
    }
    

    Perhaps this helps debugging?

    I think this printEnvVariables.py were being used for the old pythonTerminalEnvVarActivation

    For things like starship prompt please try out the new shellStartup way:

    Try install https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-python-envs , and download the latest-pre-release.

    Please set python-envs.terminal.autoActivationType to shellStartup in your settings.
    Also add "python.useEnvironmentsExtension": true, to your settings.json.

  11. Jaapel commented on Jan 28, 2026

    @Jaapel

    python-envs.terminal.autoActivationType

    Went back to this issue again. This python-envs.terminal.autoActivationType setting is grayed out and does not change behaviour.

  12. anthonykim1 commented on Jan 28, 2026

    @anthonykim1

    Jaap Langemeijer (@Jaapel) Check if higher scope is overriding it, such as workspace setting overriding user settings, etc

    Do you have environment extension enabled and installed?

  13. Jaapel commented on Jan 29, 2026

    @Jaapel

    Yes I have the environment extension enabled!

    For now I got it working by removing the environment extension.

  14. irm-codebase commented on Feb 4, 2026

    @irm-codebase

    Anthony Kim (@anthonykim1) any hope of this getting fixed?
    it's making debugging pixi projects very difficult on our end

  15. irm-codebase commented on Feb 4, 2026

    @irm-codebase

    I can provide additional context if necessary. Anything to get this done.

  16. hadim commented on Feb 19, 2026

    @hadim

    I'm experiencing the same root cause but affecting Jupyter kernel startup (not the debugger). Every kernel start/restart is delayed by exactly 30s due to the Failed to get activated env vars timeout with Pixi environments.

    I've opened a dedicated issue for this case: #25804

  17. anthonykim1 commented on Mar 13, 2026

    @anthonykim1

    The terminal activation interfering with debugger launch is likely caused by the legacy command-based activation mechanism, which sends activation commands into the terminal's command stream.

    Please try migrating to the Python Environments extension's shellStartup activation, which injects activation into your shell profile instead — keeping the command stream clean for the debugger:

    1. Set python-envs.terminal.autoActivationType to shellStartup in your settings
    2. Add "python.useEnvironmentsExtension": true to your settings.json

    See more details here: https://code.visualstudio.com/updates/v1_106#_consolidated-shell-integration-timeout-setting

    Also see #25291 for the full migration guide. Please let us know if this resolves the issue!

  18. RaphaelMelanconAtBentley commented on Mar 18, 2026

    @RaphaelMelanconAtBentley
    Author

    I wish I could migrate to using the new extension, but it does not seem to work well with multi-root workspaces yet. I have create an issue about this with a reproduction example, but have had no response to it: microsoft/vscode-python-environments#1107

  19. lukaslcf commented on Apr 9, 2026

    @lukaslcf

    Still have the same issue even using shellStartup option. I am using remote environment if that gives extra context to the problem.

  20. github-actions commented on May 10, 2026

    @github-actions

    Hey Anthony Kim (@anthonykim1), this issue might need further attention.

    Raphaël Melançon (@RaphaelMelanconAtBentley), you can help us out by closing this issue if the problem no longer exists, or adding more information.

  21. github-actions commented on Jun 9, 2026

    @github-actions

    Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

    Happy Coding!

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

Metadata

Metadata

Labels

area-terminalbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions