-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Debug adapter doesn't send pathMappings to local container #14820
Comments
@yajo I am assuming you are launching the debugger with As a workaround you should be able to use host as |
Indeed.
That doesn't resolve: $ ping loopback
ping: loopback: Name or service not known |
@karthiknadig Does pydevd still need the path mappings for localhost case? |
@int19h But this is in the container, so mapping is needed right? |
Yes, but if I understand the issue correctly, the problem is that the fix-up code kicks in and replaces the manually configured path mappings. So if we don't actually need the fix-up anymore, removing it would fix this issue also. But I'm not so sure about it... looking at the fix-up code, what it actually does is expand Anyway, I think the problem here is that it the fix-up code immediately returns an empty array if vscode-python/src/client/debugger/extension/configuration/resolvers/attach.ts Lines 86 to 126 in 24365d1
|
Please notice that, after applying the workaround explained above, I hit microsoft/debugpy#482 which also has relation with some wrong path mappings. May both be related? I appreciate a lot your interest in these issues, such a powerful tool like this is becoming a nightmare when debugging. 😿 |
I don't think the two are directly related - it's just that unblocking you on this issue means that now debugpy gets to see the entirety of your path mappings, and we weren't handling the prefixes quite right when it's a complicated hierarchy. That issue already has a PR to fix it. |
Nice, and it seems it got fixed already. OK, then regarding thisissue, my question is: if you're developing locally (without containers), why in the world would you ever need any path mappings? 🤔 If there's no use for that, then possibly the best you can do is apply the mappings always, regardless it's localhost or not. |
If the app being debugged is running on the same file system as VSCode, you do not need them, generally speaking. But you can still use path mapping to translate filenames in that case - e.g. if you're running your code from site-packages, but want the editor to show the original repo. |
I think that's weird, but in any case it seems that removing the specific restrictions for localhost is the way to go. |
Closing as stale |
Issue Type: Bug
This is how
isLocalHost()
function is implemented:vscode-python/src/client/debugger/extension/configuration/resolvers/base.ts
Lines 108 to 111 in 411d1d4
However, in my scenario, the python app I'm attaching to runs inside a docker container, and my dev laptop is the docker host. This means that I have to connect to
localhost
to debug the app, butlocalhost
is not my local host; it's the container.My guess is that there's a false positive in this code:
vscode-python/src/client/debugger/extension/configuration/resolvers/attach.ts
Lines 123 to 126 in 411d1d4
This is my launch configuration (there are several; the one that affects this issue is called "Attach Python debugger to running container"). You can see that it has lots of path mappings because this is a complex multi-root project. Also you can see that it connects to
"host": "localhost"
.If I enable debugpy logging inside the container, I will be able to see this attach request. Obviously, the breakpoints cannot resolve while debugging:
I can see that if I change my launch configuration to attach to
"host": "0.0.0.0"
instead of"host": "localhost"
(which also happens to resolve to localhost but will returnisLocalHost() -> false
), this is the attach request that debugpy reports.This looks more like what it should be. Now my breakpoints appear as properly mapped while debugging:
Note: randomly the problem just disappears and it connects properly with path mappings to localhost. Some colleagues with my same OS, the same project, commit and VSCode+extensions versions cannot reproduce. CC @joao-p-marques. However, I have noticed that it seems to work 100% of the time when using
"host": "0.0.0.0"
. Weird bug... 😵Extension version: 2020.11.371526539
VS Code version: Code 1.51.1 (e5a624b788d92b8d34d1392e4c4d9789406efe8f, 2020-11-10T23:31:29.624Z)
OS version: Linux x64 5.9.8-200.fc33.x86_64
System Info
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: