microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.77k stars 29.11k forks source link

Python debugger doesn't allow env property #210313

Closed llamafilm closed 6 months ago

llamafilm commented 6 months ago

Type: Bug

I'm trying to add environment variables to a Python debugger using the below launch.json. It shows an error under env that "Property env is not allowed." The documentation here says env is allowed.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Attach Local",
      "type": "debugpy",
      "request": "attach",
      "connect": {
        "port": 5678,
        "host": "localhost"
      },
      "justMyCode": false,
      "env": {
        "PYTEST_ADDOPTS": "--no-cov"
      },
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}",
          "remoteRoot": "."
        }
      ]
    }
  ]
}

VS Code version: Code 1.88.1 (Universal) (e170252f762678dec6ca2cc69aba1570769a5d39, 2024-04-10T17:42:52.765Z) OS version: Darwin arm64 22.6.0 Modes: Remote OS version: Linux arm64 6.6.16-linuxkit

System Info |Item|Value| |---|---| |CPUs|Apple M2 Pro (12 x 24)| |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
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|3, 3, 3| |Memory (System)|16.00GB (0.08GB free)| |Process Argv|--crash-reporter-id 11e589b2-48d6-4af6-9407-725f0132c526| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|Dev Container: Tesla Custom Component @ desktop-linux| |OS|Linux arm64 6.6.16-linuxkit| |CPUs|unknown (12 x 0)| |Memory (System)|7.66GB (5.03GB free)| |VM|0%|
Extensions (23) Extension|Author (truncated)|Version ---|---|--- coder-remote|cod|0.1.29 jupyter-keymap|ms-|1.1.2 remote-containers|ms-|0.338.1 remote-ssh|ms-|0.107.0 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.81.8 vscode-remote-extensionpack|ms-|0.24.0 remote-explorer|ms-|0.4.1 remote-server|ms-|1.5.0 river|rfr|0.1.0-alpha.2 mib|Ver|0.0.4 vscode-eslint|dba|2.4.4 vscode-pull-request-github|Git|0.86.1 debugpy|ms-|2024.4.0 pylint|ms-|2023.10.1 python|ms-|2024.4.1 vscode-pylance|ms-|2024.4.1 live-server|ms-|0.4.13 rust-analyzer|rus|0.3.1916 vscode-coverage-gutters|rya|2.11.1 crates|ser|0.6.6 even-better-toml|tam|0.19.2 vscode-lldb|vad|1.10.0 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:31000449 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 d34g3935:30971562 fegfb526:30981948 bg6jg535:30979843 ccp2r3:30993541 dsvsc020:30976470 pythonait:31006305 gee8j676:31009558 dsvsc021:30996838 gd77d436:30999572 0ee40948:31013168 ```
llamafilm commented 6 months ago
image
IllusionMH commented 6 months ago

That's correct error, as attach doesn't support this property because it connects to already running process and can't change that. Env would work on launch config.

This config is provided by extension anyway (see https://github.com/microsoft/vscode-python/blob/main/package.json#L910), but there is no bug or missing feature.