aloof-appointment-30987
11/30/2022, 10:20 PMpants run --debug-adapter apps/python/example_app/app.py
which launches and waits with Launching debug adapter at '127.0.0.1:5678...'
I then started the remote attach config.
The program continues and prints to the VSCode Debug Console but does not stop on break points. So I tried PyCharm and was able to successfully debug by hosting a debug server and including in my python code:
import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=5150, stdoutToServer=True, stderrToServer=True)
It does not map to the original source file but I'm able to step through with the debugger in PyCharm.
I then tried to get VSCode working and found that with the above pydevd_pycharm
code in place, I can debug in VSCode as well. It also does not map to the original source file but I can connect to the remote session and step through the code.
If I remove or comment the pydevd_pycharm
code, I see the original behavior where the console messages print to the debug console but execution is not halted.
Thoughts on what I may be missing?happy-kitchen-89482
11/30/2022, 11:39 PMpydevd_pycharm
(with PyCharm) and it works like a, um, charm…bitter-ability-32190
11/30/2022, 11:42 PMaloof-appointment-30987
11/30/2022, 11:42 PMbitter-ability-32190
11/30/2022, 11:44 PMbitter-ability-32190
11/30/2022, 11:45 PMbitter-ability-32190
11/30/2022, 11:49 PMbitter-ability-32190
12/01/2022, 1:01 AMaloof-appointment-30987
12/01/2022, 7:18 PMPANTS_SHA=008fe0940bf1e870334d4f2dbe7cbf295f15c607 ./pants --version
That's the latest hash from https://github.com/pantsbuild/pants/tree/2.15.x where https://github.com/pantsbuild/pants/issues/17540 was merged.
It does not map to the source file so break points aren't hit. I can, however, halt in code and attach as before, and step through the sandbox source. I see the message
0.00s - pydev debugger: unable to find translation for: "/private/var/folders/_d/zt8y2x055597l63bhdztp82c0000gn/T/pants-sandbox-4suXBa/apps/python/example_app/app.py" in ["/Users/russellzarse/dev/optios/monorepo_example/", "/Users/russellzarse/dev/optios/monorepo_example"] (please revise your path mappings).
My .env
file contains
PYTHONPATH="./.:./apps/python/example_app:./apps/python/monorepo_util/src:./libraries/python/another_library:./libraries/python/content_module/src:./libraries/python/quoteoftheday:$PYTHONPATH"
My understanding of the docs at [Setting up an IDE](https://www.pantsbuild.org/docs/setting-up-an-ide#first-party-sources) is that the PYTHONPATH
is picked up from the .env
file by vsCode. Is there another place where path mappings is configured?bitter-ability-32190
12/01/2022, 7:21 PMsource_roots
set to?
• Is your VS Code launch,json
sending pathMappings
? If so, what are they?aloof-appointment-30987
12/01/2022, 7:26 PM> ./pants roots
14:23:18.84 [INFO] Initialization options changed: reinitializing scheduler...
14:23:19.55 [INFO] Scheduler initialized.
.
apps/python/example_app
apps/python/monorepo_util/src
libraries/python/another_library
libraries/python/content_module/src
libraries/python/quoteoftheday
VSCode launch.json Config
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
],
"justMyCode": true
}