microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.29k stars 292 forks source link

Breakpoint in Notebook Cell doesn't stop when VSCode is running on Windows and Kernel running on Linux #15934

Open jersonchua opened 2 months ago

jersonchua commented 2 months ago

Applies To

What happened?

I'm facing is the same issue reported in https://github.com/microsoft/vscode-jupyter/issues/11396 with slightly different setup. My kernel is running in a linux container specifically https://hub.docker.com/layers/amazon/aws-glue-libs/glue_libs_4.0.0_image_01/images/sha256-bd642d06ee69c7eac710080091c5c76dfbf28005bb81541d475ab5846851368c?context=explore

ipykernel: 6.20.2 debugpy: 1.80 python: 3.10.2

VS Code Version

1.88.1

Jupyter Extension Version

v2023.11.1003402403

Jupyter logs

sourcePath in dumpCell has forward slash

2024-08-09 15:01:14.644 info: < {"header": {"msg_id": "491ec245-2cadc611fe3575525aa4b73a_338_103", "msg_type": "debug_reply", "username": "glue_user", "session": "491ec245-2cadc611fe3575525aa4b73a", "date": "2024-08-09T19:01:14.570370Z", "version": "5.3"}, "msg_id": "491ec245-2cadc611fe3575525aa4b73a_338_103", "msg_type": "debug_reply", "parent_header": {"date": "2024-08-09T19:01:14.093000Z", "msg_id": "21d47a00-7e31-4fea-b50b-b03e371a1bc5", "msg_type": "debug_request", "session": "bdc61c4a-6655-4165-bfc7-0e1360b7751e", "username": "", "version": "5.2"}, "metadata": {}, "content": {"type": "response", "request_seq": 15, "success": true, "command": "dumpCell", "body": {"sourcePath": "/tmp/ipykernel_338/2523026605.py"}}, "buffers": [], "channel": "control"}

path in setBreakpoints has back slash. I think this is caused by the path normalization logic in the extension.

2024-08-09 15:01:14.662 info: > {"buffers":[],"channel":"control","content":{"seq":10,"type":"request","command":"setBreakpoints","arguments":{"source":{"name":"Untitled-1.ipynb","path":"\tmp\ipykernel_338\2523026605.py"},"lines":[2],"breakpoints":[{"line":2}],"sourceModified":false}},"header":{"date":"2024-08-09T19:01:14.662Z","msg_id":"c5f0353e-a3d8-4cdf-b14c-df854ef4c0ae","msg_type":"debug_request","session":"bdc61c4a-6655-4165-bfc7-0e1360b7751e","username":"","version":"5.2"},"metadata":{},"parent_header":{}}

And because the path has the back slash, the debugger returned "Breakpoint in file that does not exist"
2024-08-09 15:01:14.737 info: < {"header": {"msg_id": "491ec245-2cadc611fe3575525aa4b73a_338_109", "msg_type": "debug_reply", "username": "glue_user", "session": "491ec245-2cadc611fe3575525aa4b73a", "date": "2024-08-09T19:01:14.669487Z", "version": "5.3"}, "msg_id": "491ec245-2cadc611fe3575525aa4b73a_338_109", "msg_type": "debug_reply", "parent_header": {"date": "2024-08-09T19:01:14.662000Z", "msg_id": "c5f0353e-a3d8-4cdf-b14c-df854ef4c0ae", "msg_type": "debug_request", "session": "bdc61c4a-6655-4165-bfc7-0e1360b7751e", "username": "", "version": "5.2"}, "metadata": {}, "content": {"seq": 25, "type": "response", "request_seq": 10, "success": true, "command": "setBreakpoints", "body": {"breakpoints": [{"verified": false, "id": 1, "message": "Breakpoint in file that does not exist.", "source": {"name": "Untitled-1.ipynb", "path": "\tmp\ipykernel_338\2523026605.py"}, "line": 2}]}}, "buffers": [], "channel": "control"}

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

None

DonJayamanne commented 2 months ago

Thank you for filing this issue, are you able to update ipykernel & debugpyto the latest version and see if this repros Also, please update your version of VS Code, Jupyter and Python extensions to the latest versions (as you have some fairly old versions).

jersonchua commented 2 months ago

@DonJayamanne I upgraded to debugpy1.8.5 and ipykernel 6.29.5. Breakpoint still doesn't stop and I'm also seeing the same "Breakpoint in file that does not exist." response back to the extension.

2024-08-12 16:27:52.939 info: < {"header": {"msg_id": "92864651-d7ccc49aafaa8fea48fc6f90_890_199", "msg_type": "debug_reply", "username": "glue_user", "session": "92864651-d7ccc49aafaa8fea48fc6f90", "date": "2024-08-12T20:27:52.918384Z", "version": "5.3"}, "msg_id": "92864651-d7ccc49aafaa8fea48fc6f90_890_199", "msg_type": "debug_reply", "parent_header": {"date": "2024-08-12T20:27:52.879000Z", "msg_id": "2980f59e-2749-4adb-8057-8c203786dd59", "msg_type": "debug_request", "session": "a9817bd4-ad93-4961-9ff0-67ccdd12bbd8", "username": "", "version": "5.2"}, "metadata": {}, "content": {"seq": 26, "type": "response", "request_seq": 10, "success": true, "command": "setBreakpoints", "body": {"breakpoints": [{"verified": false, "id": 0, "message": "Breakpoint in file that does not exist.", "source": {"name": "Untitled-1.ipynb", "path": "\tmp\ipykernel_890\3773950048.py"}, "line": 1}]}}, "buffers": [], "channel": "control"}

jersonchua commented 2 months ago

Looking at the latest version of the code, I see that path.normalize is still getting called for sourcePath. From I understand in the code, path.normalize is the one flipping / to \ in the sourcePath. @adam-zlatniczki tried to fix this before as you can see in https://github.com/microsoft/vscode-jupyter/issues/11396

https://github.com/microsoft/vscode-jupyter/blob/2a11eb0be0db775560232006cd86d67dfcee3a11/src/interactive-window/debugger/jupyter/kernelDebugAdapter.ts#L90

https://github.com/microsoft/vscode-jupyter/blob/2a11eb0be0db775560232006cd86d67dfcee3a11/src/notebooks/debugger/kernelDebugAdapter.ts#L23