-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression compared to ptvsd: debugging python running in a bazel runtime sandbox causes duplicate tabs to open #743
Comments
We have to consider this an enhancement, since the symlink-resolution side effect of path mapping was an implementation detail that was not meant to be relied on specifically. Since path mapping is not really suitable here due to all the issues that you've mentioned, I think we just need a flag that would make the debug server flow all code paths via |
@int19h, agreeing with all you said. Having that flag would be awesome. I'm not sure if it would better go in the launch.json debug config or as a flag to debugpy. Either would work fine for me. |
@koenlek since you're already using a workflow where you stop the debugger and then wait for the client to connect, one approach which could already work is using the API to set the path mappings instead of specifying it from the launch json. i.e.: You should be able to use something as:
With that, you should be able to provide the -- note: this can be called before the connection if don't specify any |
@fabioz, thanks, that's a useful pointer. It actually looks like the vendored pydevd already provides tooling to map things to their canonical path, see For someone with a bit more knowledge of |
@judej, I noticed this was added to Dev 17.x milestone. Does this mean it's being considered for implementation? And if so, within what time frame? Would be great if this get's addressed! |
Bump on this request. This is a major quality of UX issue when using debugpy with bazel sandboxes, so would be great if someone can shed light on any (tentative) roadmap for this 🙏 |
I'll start to take a look at this. |
@int19h what do you think should be the name of the flag? I'm thinking about having an environment variable:
which may be overridden in specific launch configurations with a:
property. |
Sounds good to me! |
SGTM too! |
@koenlek As a note, the actual fix (without the work related to the options/env vars) is mostly a one-line change at: fabioz@a0783bb#diff-82a2e0a4303124b25a3c6acce599deec12927c414ac18a226a3c6d8dc34384dcR405 (in the You can probably do that change locally to check if it works until a new release is done. If you're running in the debugger you can do:
and then you can hardcode the change to do:
inside the |
Thanks for implementing this, @fabioz! When do you expect this to be released? Or can I use a pre-release to test it? |
@fabioz, I'm able to use this by setting the env var |
Context
When using python in a bazel sandbox (
bazel run //python/target
), bazel symlinks the required files into a 'runfiles' sandbox. My approach to debugging is to run it under the debugger and make it wait for client to connect (formerly ptvsd, now I'm exploring switching to debugpy).Once attached, breakpoints trigger, but open a copy of the file at the sandbox path (with some visual quirks, such as that breakpoints don't visually sync between both copies, see screenshot). This pollutes tabs and makes debugging messy, especially when doing complex debugging sessions that involve many files.
This screenshot shows both the double tabs issue, as well as they breakpoints visually not synchronizing between both copies of the same file.
With
ptvsd
, there was a simple workaround for this issue, just add this to the launch.json debug config:This seemingly no-op mapping effectively solved this issue, presumably because as part of the path mapping, it canonicalizes the path (like
os.path.realpath
in python, orreadlink -f
in bash for macos and linux) in the process, causing breakpoints to cleanly trigger in the original files.You might as yourself: why not just do this:
This isn't tractable for 2 reasons:
I'd like to switch from
ptvsd
todebugpy
, as debugpy has significantly better multiprocess handling. But this issue is a major blocker.Environment data
Actual behavior
ptvsd
the pathmapping trick works to avoid opening sandbox copies of files.dedubpy
the pathmapping trick does not work to avoid opening sandbox copies of files.Expected behavior
I'd expect both to work. Either through the pathmappings trick, or through some other way such as introducing a new that
canonicalizes
paths.As I believe
debugpy
was forked fromptvsd
, we could maybe compare code and see what tweak is needed to make the pathmappings trick work again.Steps to reproduce:
I've created a small example environment in which this issue can easily be reproduced. Please open this folder as a workspace in vscode and follow the instructions in the readme.
debugpy_issue.zip
The text was updated successfully, but these errors were encountered: