microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
41 stars 17 forks source link

Something about my package makes debugger not stop on breakpoints #271

Closed kjohnsen closed 3 weeks ago

kjohnsen commented 3 months ago

Type: Bug

Behaviour

The debugger doesn't stop on breakpoints or errors, but only when importing my package. I can't figure out what it is in my setup that's breaking it. I tried creating a minimal example with a poetry project, but it doesn't reproduce the error, so here are the steps to reproduce with my codebase. The Python and Python Debugger output tabs don't appear to give any hints.

Things I tried that didn't reproduce the error (the debugger did work as expected):

So it's something about a poetry install and something out of the ordinary in my code that (partially) breaks the debugger

Steps to reproduce:

  1. gh repo clone siplab-gt/cleo@wslfp && cd cleo
  2. poetry install && poetry env info, select VS Code interpreter to be the one in the virtualenv automatically created by Poetry
  3. Create a Python file with print('code executed') in it, stick a breakpoint on it, click 'debug Python file' button, and verify breakpoint works
  4. Stick import cleo (my package) at the top and debug file again. Verify that the code still executes (prints to console) but no breakpoint is triggered

Diagnostic data

launch.json configuration

``` XXX ```

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

``` 2024-03-18 19:15:59.745 [info] Send text to terminal:  2024-03-18 19:15:59.745 [info] Send text to terminal: cd /home/kyle/scratch/cleo-test ; /home/kyle/miniforge3/envs/test/bin/python /home/kyle/.vscode-server-insiders/extensions/ms-python.debugpy-2024.3.10731008-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 47137 -- /home/kyle/scratch/cleo-test/foo.py ```

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

``` 2024-03-18 19:15:59.531 [info] DAP Server launched with command: /home/kyle/miniforge3/envs/test/bin/python /home/kyle/.vscode-server-insiders/extensions/ms-python.debugpy-2024.3.10731008-linux-x64/bundled/libs/debugpy/adapter ```

Extension version: 2024.3.10731008 VS Code version: Code - Insiders 1.88.0-insider (b356b209a5a41743b45f25d569a7afb733d347a9, 2024-03-18T16:36:07.814Z) OS version: Windows_NT x64 10.0.22631 Modes: Remote OS version: Linux x64 5.15.146.1-microsoft-standard-WSL2 Remote OS version: Linux x64 5.15.146.1-microsoft-standard-WSL2 Remote OS version: Linux x64 5.15.146.1-microsoft-standard-WSL2

Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
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
Load (avg) undefined
Memory (System) 31.73GB (7.06GB free)
Process Argv --crash-reporter-id 13862219-8062-4bb8-969d-b654fdb7b5e1
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu-22.04
OS Linux x64 5.15.146.1-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
Memory (System) 15.49GB (9.44GB free)
VM 0%
Item Value
Remote WSL: Ubuntu-22.04
OS Linux x64 5.15.146.1-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
Memory (System) 15.49GB (9.44GB free)
VM 0%
Item Value
Remote WSL: Ubuntu-22.04
OS Linux x64 5.15.146.1-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
Memory (System) 15.49GB (9.44GB free)
VM 0%

A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
vsaa593cf:30376535
py29gd2263:30784851
c4g48928:30535728
962ge761:30841072
pythongtdpath:30726887
welcomedialog:30812478
pythonidxpt:30768918
pythonnoceb:30776497
asynctok:30898717
dsvsc013:30777762
dsvsc014:30777825
dsvsc015:30821418
pythontestfixt:30866404
pythonregdiag2:30926734
pyreplss1:30879911
pythonmypyd1:30859725
pythoncet0:30859736
h48ei257:30992801
pythontbext0:30879054
accentitlementst:30870582
dsvsc016:30879898
dsvsc017:30880771
dsvsc018:30880772
d6fi2104:30968146
pydisww1:30991133
cppperfnew:30980852
8082a590:30961435
fegfb526:30952798
bg6jg535:30979844
ccp1r6:30958151
pythonait:30973460
7ghi1836:30988844

gitcheol commented 3 months ago

i had a same issue when import some packages. my case was duplication of package(local and global with python environment variables). so my vscode could not find the appropriate packages in my workspace. please check the package duplication with your code. maybe the main process is using other located same named packages.

good luck!

kjohnsen commented 2 months ago

What do you mean package duplication? I mean, the import would have the choice between the poetry install and the local folder when I call import cleo, but that's a typical workflow

paulacamargo25 commented 3 weeks ago

Thanks for you bug report, but the issue seems to be an error in your code and not in the extension itself. What may be happening is that somehow one of your python files is overwriting one of the ones used for the debugger. You can create an issue in debugpy, maybe they can help you.