0

I am using Visual Code 1.55.2 on Ubuntu 20.04 LTS. I have a simple problem, i.e. I cannot trigger breakpoints if they are in a subfolder of my project's one. This is my launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Main",
            "type": "python",
            "request": "launch",
            "program": "Main.py",
            "console": "integratedTerminal",
            "cwd": "${fileDirname}"
        }
    ]
}

I added the cwd attribute and specified the program name and file to be run. So now, whenever I click on my debug configuration everything works fine, apart from the fact that some breakpoints are ignored. This is a facsimile of my working directory:

.
├── subfolder
│   ├── subfile1.py
│   └── subfile2.py
├── file1.py
├── file2.py
├── file3.py
├── file4.py
├── Main.py
└── .vscode
    └── settings.json

All the breakpoints in subfile1.py and subfile2.py are ignored.

I have tried to read the official documentation, but I could not understand it well enough.

Thanks for your help!

--- UPDATE ---

Sadly, I am not allowed to share my code, so I can olny describe the problem by words or via examples.

That said, I just finished testing some more this issue, and I discovered that subfolders are not a problem per se, but, regardless, the debugger skips a breakpointed line in my code that I am sure gets read The breakpointed line is correctly listed In the "Run and Debug" tab, "breakpoints" section, like the sample in the figure below (Notice that the "Python: Main" config file content is shown in the previous paragraph):

breakpoint correctly listed in my sample code

In fact, my problems with VS code started as soon as I decided to debug this project with it instead of relying on pyCharm, which had been working fine, without any issue. To provide some more conxtext, I can say that my project involves PyQt5, so it creates an interactive window on screen. The code portion I am testing should trigger after ask the program to open a file via a button on the GUI (which works fine), and then I actually pick a file from the OS-managed file explorer. Sadly, the breakpoint does not trigger. With pyCharm, everything works as expected: once I get to that specific line, the code stops. This does not happen with VS code, so either the debugger behaves differently or there are some settings that need to be tweaked. The only VS code "tweaking/settings variable" I know about is the launch.json.

Given these new insights, the problem seems more a sort of unresponsiveness from the IDE, because if I set a breakpoint at the first line of that specific file, the debugger actually stops there. So what I tried next was to leave both the breakpoints on (the one at the first line and the "not-triggering" one), and see what happens: the first breakpoint works, the second one is still ignored. I am using the anaconda "base" environment and its interpreter in both IDEs, if that matters.

Jetboy
  • 129
  • 8
  • Can you share the code for me to reproduce your question if convenient? Besides, post a gif about debugging with breakpoints can explain your question more clearly. – Molly Wang-MSFT Apr 25 '21 at 03:01
  • @MollyWang Thank you for your interest. I just updated my question with another paragraph. Sadly, I am not allowed to share this code publicly. Anyway, I totally understand that, in your side, trying to understand the issue based solely on my descriptions can be very hard and time consuming, so I would completely understand if you decided to opt-out. But, maybe, even just some suggestions on what I could try to solve/investigate further the problem could be really helpful anyway! – Jetboy Apr 25 '21 at 13:13

1 Answers1

1

Use the default debug configuration and try again:

"configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",  
        }
    ]

enter image description here

More information about debug please view Debugging and Python debug configurations in Visual Studio Code.

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22
  • Thank you for your time. I just tried generating and applying the default configuration and it sadly does not work. I'll have a look at the two links you provided. Anyway, I realized too late that the problem might be more complicated than just being related to relative folder paths, so I'll need to make more experiments before actually having a clearer picture. Nonetheless, thank you very much again! – Jetboy Apr 26 '21 at 10:59
  • I tought a bit more about it, and as my question turned out not to be that precise, I think I'll mark you answer as "accepted" anyway, as you probably have made the best out of what I have described – Jetboy Apr 26 '21 at 11:20
  • 1
    Thanks for your kindness. You may ask it in [microsoft/vscode-python](https://github.com/microsoft/vscode-python/issues) for more help. – Molly Wang-MSFT Apr 27 '21 at 01:38
  • Hi, I do not know if you are interested in the issue per se or if you just wanted to help me, but in case of the former, I had tome time to investigate further: I'm pretty sure the issue is related to how vs code debugger handles pyqt5 (which I was using inside that project). Here I think there's one guy, for instance, having a similar issue: https://github.com/microsoft/vscode-python/issues/176#issuecomment-389082563 I was to point out that I am not asking for help, as I also finished working on that project with pyCharm, but maybe you were/are still puzzled by what was the issue I had :) – Jetboy May 26 '21 at 12:38
  • @Jetboy. Thank you and I'll have a look at the issue. :) – Molly Wang-MSFT May 27 '21 at 01:05