Repository navigation
Closed
Description
Having trouble attaching a debugger to Python code that's running in a Docker instance.
Similar problem to this issue
But I followed the steps there and I'm still having issues.
Firstly, I made sure I'm running the Debug Adapter Protocol in debug mode, not in Run mode.
I also made sure the breakpoints I'm settings are getting set as DAP breakpoints, not as Python breakpoints.
The rub here is that I'm able to connect my debugger in VS Code just fine. This is the launch.json in my VS Code:
{
"name": "Debug MyCode server",
"type": "python",
"request": "attach",
"pathMappings": [
{
"localRoot": "/Users/amizanjaleel/src/mycode",
"remoteRoot": "/usr/src/mycode"
}
],
"port": 9000,
"host": "127.0.0.1"
}
In my Python code I have:
import debugpy
debugpy.listen(("0.0.0.0", 9000))
When I run my run configuration in debug mode, I see it getting attached to the Python code running in Docker, because I see this getting printed out:
Attaching 'Python - Debugpy' at 127.0.0.1:9000
[Trace - 19:40:46] Sending request 'initialize - (1)'.
[Trace - 19:40:46] Received notification 'output'
ptvsd
[Trace - 19:40:46] Received notification 'output'
debugpy
[Trace - 19:40:46] Received notification 'debugpySockets'
[Trace - 19:40:46] Received response 'initialize - (1)' in 2ms.
[Trace - 19:40:46] Sending request 'attach - (2)'.
[Trace - 19:40:46] Received notification 'debugpyWaitingForServer'
[Trace - 19:40:46] Received notification 'initialized'
[Trace - 19:40:46] Sending request 'configurationDone - (3)'.
[Trace - 19:40:46] Received response 'configurationDone - (3)' in 44ms.
[Trace - 19:40:46] Received response 'attach - (2)' in 135ms.
[Trace - 19:40:46] Received notification 'process'
[Trace - 19:40:46] Received notification 'thread'
[Trace - 19:40:46] Received notification 'thread'
[Trace - 19:40:48] Sending request 'setBreakpoints - (4)'.
[Trace - 19:40:48] Received response 'setBreakpoints - (4)' in 5ms.
However, my breakpoints do not get hit.
Activity
angelozerr commentedon Apr 17, 2025
@amizan-jaleel coud you share your full DAP log with verbose. Thanks.
amizan-jaleel commentedon Apr 17, 2025
@angelozerr Thanks for the tip, I can see the error now:
However, I can't fathom why this would come up. I'm certain the
remoteRootis set properly. It is the sameremoteRootthat is set for VS Code, and that one works just fineangelozerr commentedon Apr 17, 2025
Could you share your full trace please.
fix: normalize path of breakpoint
angelozerr commentedon Apr 17, 2025
Your path uses
../,please share your trace to understand why you have that.amizan-jaleel commentedon Apr 17, 2025
No no sorry for the confusion, I left out some of the directory structure since I think it's not pertinent, let me share the full stacktrace
amizan-jaleel commentedon Apr 17, 2025
angelozerr commentedon Apr 17, 2025
It seems that the problem is when breakoints are sent to debugpy server.
The path
/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/tasks_input.pyis wrong and should be/Users/amizanjaleel/src/mycode/mycode_inventory/tasks_input.py, right?amizan-jaleel commentedon Apr 17, 2025
No, that's actually the right path heh
angelozerr commentedon Apr 17, 2025
Having mycode/mycode was suspicious but it seems it is ok.
It
II have no idea why you have this issue if you tell me that path is correct
amizan-jaleel commentedon Apr 17, 2025
Yeah it's for certain that path is correct. When it's printed in my debug window, I see a hyperlink and when I click it it opens that file in my IDE. That's why I was thinking when it says it can't find the file, it meant on the remote side. But I'm sure my remoteRoot is correct as well.
I'm sure the process is connecting correctly too. When I add print statements in my Python code, I see that getting printed out in my debug console, even though the code is running in Docker.
angelozerr commentedon Apr 17, 2025
Is it working with simple debugging like described in https://github.com/redhat-developer/lsp4ij/blob/main/docs%2Fdap%2Fuser-defined-dap%2Fpython-debugpy.md
angelozerr commentedon Apr 18, 2025
Your config is working on vscode, right?
angelozerr commentedon May 2, 2025
@amizan-jaleel I have improved DAP breakpoint support, I don't know if it could fix your issue.
Could you please install https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds and give me feedback.
Thanks.
angelozerr commentedon May 14, 2025
@amizan-jaleel could you install LSP4IJ 0.13.0 which has been released and tell me if it is working better? Thanks!
angelozerr commentedon May 21, 2025
@amizan-jaleel I close this issue because LSP4IJ have fixed a lot of problem with breakpoints.
Please reopen it if it doesn't work. Thanks.