Question about debugging in VSCode. I set up a Py...
# general
Question about debugging in VSCode. I set up a Python: Remote Attach VSCode configuration and launched my app with
pants run --debug-adapter apps/python/example_app/
which launches and waits with
Launching debug adapter at ''
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:
Copy 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
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
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?
I’ll defer to @bitter-ability-32190 on this. I always use
(with PyCharm) and it works like a, um, charm…
I recently fixed a bug, which this sounds like. Can you try with bleeding edge Pants?
I’ll try that tomorrow and let you know! Thanks.
The razor is: what are your source roots
Oh wait, you can just use PANTS_SHA since this was merged:
Oh and the issue at Play behind all this is that the "server" is running with CWD set to your build root, but sources from the sandbox. So the path mappings that the client provides are essentially impossible to configure. Hence no breakpoints get hit
I was able to run using
PANTS_SHA=008fe0940bf1e870334d4f2dbe7cbf295f15c607 ./pants --version
That's the latest hash from where 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
Copy code
0.00s - pydev debugger: unable to find translation for: "/private/var/folders/_d/zt8y2x055597l63bhdztp82c0000gn/T/pants-sandbox-4suXBa/apps/python/example_app/" in ["/Users/russellzarse/dev/optios/monorepo_example/", "/Users/russellzarse/dev/optios/monorepo_example"] (please revise your path mappings).
file contains
Copy code
My understanding of the docs at [Setting up an IDE]( is that the
is picked up from the
file by vsCode. Is there another place where path mappings is configured?
There's a very good chance this needs additional massaging on Mac. The error line you mention is perplexing as none of the values configured appear to be the chroot. Two questions just for background: • What's your
set to? • Is your VS Code
? If so, what are they?
Copy code
> ./pants roots
14:23:18.84 [INFO] Initialization options changed: reinitializing scheduler...
14:23:19.55 [INFO] Scheduler initialized.
VSCode launch.json Config
Copy code
  "name": "Python: Remote Attach",
  "type": "python",
  "request": "attach",
  "connect": {
    "host": "localhost",
    "port": 5678
  "pathMappings": [
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "."
  "justMyCode": true