-
Notifications
You must be signed in to change notification settings - Fork 147
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
Duplicate tabs when using pyfakefs #1709
Comments
There's two things I can think of that might cause the problem. 1 - You're doing remote debugging and the pathmapping is the wrong case |
A log might help to diagnose where debugpy is attempting to bind the breakpoints. See the directions here: |
The issue where it doesn't hit breakpoints seems to have solved itself, oddly enough. It's still opening duplicate tabs though. The directions for obtaining the log seem to be out of date? I can't see any log files in |
Every time you run it generates a bunch log files. The easiest way to get us the log files is to delete them all and run once more. I'll update the directions to look for ms-python.debugpy. If the breakpoints are binding, the problem may be with VS code then. Debugpy just gives back a file path to open for a stack frame. VS code would decide if the file was a new tab or not. But the path in the log files might give us some clue. |
Similar VS code issue: |
It seems to create 5 log files with each run. There's debugger.vscode_839fb24b-acb8-4d5b-ac71-31bc2d9f37e2.log Not using remote debugging or |
Here's the response we give to VS code:
Is that casing the same as what VS code is showing in the tab? |
Yep, exactly the same. But I just noticed that the new tab is in read-only mode. That's probably the reason why it opens a 2nd one. |
Yeah, right after that VS code asks the debugger for the source. Like it's using that to create the tab. Super weird.
Why would it need to ask the debugger? @connor4312 do you know what circumstances VS code asks the debugger for the source? In a normal debug session, we only get a stack trace request. |
Your stackframe has a source with a non-zero sourcereference, which means it doesn't exist on disk, so the DA is asked for it: "stackFrames": [
{
"id": 2,
"name": "import_app_module",
"line": 113,
"column": 1,
"source": {
"path": "D:\\Users\\Aran-Fey\\Desktop\\folder\\coding\\python\\rio\\rio\\cli\\run_project\\app_loading.py",
"sourceReference": 7 // <-
}
}
], See docs for the properties in the Source type |
Okay that's here in our code then:
@Aran-Fey can you upload the pydevd log. It should have more information. |
Sorry this environment variable needs to be set globally first:
That adds more logging output for path translation. |
Is there a way to do it without having to restart my PC? (Or logging out and back in.) I have a lot of stuff open... |
I think this should work in your launch.json:
It seems to have been picked up when I did it. When the app runs, it should output something from this code if it worked:
|
I had to play around with the launch.json until the bug happened again, so these logs are from running debugpy.pydevd.18648.log |
Did you get this output?
I don't see any extra translation logging. Maybe the source reference is being set somewhere else. We'd likely need a copy of the test for this so we can debug it locally. |
I did see You can find the code here. The file is |
It's your code's fault. It's overwriting the file system. Internally we get this error when trying to detect if FileNotFoundError: [Errno 2] No such file or directory in the fake filesystem: 'C:\Users\rchiodo\source\testing\rio\tests\test_cli' That indicates to the debugger to return a source_reference. |
Great. Looks like we'll be playing a game of "it's not this tool's fault, the other one should fix it". |
The test you have is overwriting the file system. That's what I meant. It's your specific test. It's using the pyfakefs which patches the file system at the OS module level. |
This module: |
And of course it's pyfakefs's responsibility to add support for debugpy, and not the other way round. |
Yes debugpy can't determine how pyfakefs is patching the os module. Pyfakefs would need to have a way to let some file paths use the normal OS and you'd specify that in your test. |
Something must be going wrong internally with the handling of file paths. The effects I've observed are:
Hitting a breakpoint in the "current file" opens a duplicate tab.
Before starting the debugger:
After:
The file path is exactly the same.
Creating a new breakpoint in this duplicate tab creates a disabled breakpoint. (See line 89.)
Breakpoints in other files are never hit. For example, if I set a breakpoint inside my
load_user_app
function, it's completely ignored.All in all, the debugger is completely unusable.
What's also interesting is that everything works as expected if I try to reproduce it with a new, minimal file:
P.S.: No symlinks or hardlinks or directory junctions are involved. I do have a directory junction set up (from C:\ to D:), but these issues occur even if I open the project directly from the D:\ drive.
The text was updated successfully, but these errors were encountered: