Skip to content
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

.ipynb debug cell -- debugger fails to hit breakpoint #15914

Closed
p-i- opened this issue Aug 2, 2024 · 15 comments
Closed

.ipynb debug cell -- debugger fails to hit breakpoint #15914

p-i- opened this issue Aug 2, 2024 · 15 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug notebook-debugging

Comments

@p-i-
Copy link

p-i- commented Aug 2, 2024

Type: Bug

TLDR (Edited 9 Aug)

In my case the problem was fixed by toggling "Jupyter: Debug Just My Code" in Settings to ON.

Original message ...

I have VSCode opened in $root. I have $root/.venv/... (Python 3.12.3, freshly installed using pyenv (macos))

I create test.ipynb

First cell: a = 1, Second cell: b = 2. I execute the first cell. ok. I set a breakpoint on the first (and only) line of the second cell and debug-execute it.

There's no visual indication the breakpoint has been hit. And attempting to step-{in/out/over} lands me in alien code (see screenshot).

Now I try to create a fresh test case. Quit VSCode, create test/ folder, create test/.venv/ (from pyenv, identically as done per fail-case), open VSCode in test/, create x.ipynb, 2 cells a = 2 and b = 2, execute the first. ok. set breakpoint on second and debug-execute the second.

It hits! It works!

So something in my $root project is mashing the debugger.

This is bizarre and frustrating. It means I'm going to have to copy my entire codebase into a fresh project just to get the debugger working in .ipynb files.

Extension version: 2024.7.0
VS Code version: Code 1.92.0 (b1c0a14de1414fcdaa400695b4db1c0799bc3124, 2024-07-31T23:26:45.634Z)
OS version: Darwin arm64 23.5.0
Modes:

System Info
Item Value
CPUs Apple M2 (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 3, 3, 2
Memory (System) 24.00GB (2.33GB free)
Process Argv --crash-reporter-id f10d97cd-2115-4dba-a34a-07be9312995a
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonregdiag2:30936856
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
jg8ic977:31013176
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
impr_priority:31102340
refactort:31108082
ccplc:31103425
pythonrstrctxt:31103193
wkspc-onlycs-c:31106320
wkspc-ranged-c:31107834

@p-i-
Copy link
Author

p-i- commented Aug 2, 2024

Test case (works):

Screenshot 2024-08-02 at 14 30 32

Fail case (my project):
Screenshot 2024-08-02 at 14 31 21

If I click step {over/out/in} on the fail-case:
Screenshot 2024-08-02 at 14 37 38

@p-i-
Copy link
Author

p-i- commented Aug 2, 2024

Screenshot 2024-08-02 at 14 43 52

^ That's how I'm invoking debug on a cell

@p-i-
Copy link
Author

p-i- commented Aug 2, 2024

Here are the TRACE logs for Output -> Jupyter:

FAIL:
fail.txt

WIN:
win.txt

@p-i-
Copy link
Author

p-i- commented Aug 4, 2024

As a follow-up, this has hit me again.

To resolve it, I created a fresh folder, created a ./.venv, opened VSCode, copied my .ipynb and .py file into this new folder, and was able to successfully use the debugger in my .ipynb.

  • Setting breakpoints either in the .ipynb or the .py and debug-running the cell, they would hit.
  • I could navigate the call-stack and single-step debug.
  • Checking 'raised exceptions' in the "Breakpoints" pane, execution would indeed suspend at the exception, highlighting the offending line, and allowing me to use "Debug Console" pane to inspect.

Then I left VSCode running and went to sleep. And now first thing in the morning, it is again failing.

I haven't done anything fancy. All I've been doing is tweaking a numpy-heavy .py file and an .ipynb that uses it. I haven't done anything else on my mac, other than watch a YouTube video in a Chrome tab.

In fact my "fresh folder" was the folder I used for my working testcase (first screenshot).

And re-executing the test now fails. On exactly the same x.ipynb file!

I've looked through all available logs in Output pane, and see no anomaly.

This is a serious problem :/

@p-i-
Copy link
Author

p-i- commented Aug 4, 2024

As per https://stackoverflow.com/questions/56794940/vscode-why-isnt-debugger-stopping-at-breakpoints toggling "Jupyter: Debug Just My Code" in Settings to ON has gotten it working.

Screenshot 2024-08-04 at 10 42 57

Why can't I see the setting I just changed in ~/Library/Application\ Support/Code/User/settings.json? Even after a VSCode restart it's not there. And I have no .vscode/ folder in my project. I thought every settings-change creates a new entry at the bottom of this JSON list.

@DonJayamanne
Copy link
Contributor

Than you for filling this issues and sorry you are running into this
And Thank you for your detailed analysis and screenshot

I think the final conclusion would that the settings aren’t getting saved/applied correctly.

Is that correct?

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-debugging labels Aug 5, 2024
@p-i-
Copy link
Author

p-i- commented Aug 5, 2024

Let me clarify my last post. There's two complete separate things in it.

  1. Toggling "Jupyter: Debug Just My Code" to ON fixes the "debugger not working correctly" issue. Now this is a bizarre fix. So the issue should be considered as a bug IMO.

  2. After toggling this setting, I decided to inspect my User/Settings.json so that I could copy down the exact key for this setting, and was surprised to find that the setting isn't getting written to that file. I doubt this is connected to the original issue. But I am curious as to why I can't find this setting. I just checked again today and it is still not there.

@DonJayamanne
Copy link
Contributor

as to why I can't find this setting. I just checked again today and it is still not there.

Default values aren't written into settings.json
By default this value is turn on, hence you may have disabled this at some point in time.

Image

I doubt this is connected to the original issue.

Given that you are not debugging any 3rd party code and just a simple cell and its not hitting your break point.
I agree, that the setting should not really make a difference, however for now I would suggest enabling the value as that is the default value.

@p-i-
Copy link
Author

p-i- commented Aug 6, 2024

Please someone remove the info-needed tag.

@DonJayamanne DonJayamanne removed the info-needed Issue requires more information from poster label Aug 6, 2024
@DonJayamanne DonJayamanne pinned this issue Aug 6, 2024
@edervishaj
Copy link

edervishaj commented Aug 28, 2024

I have the same problem, the debugger does not stop. Moreover, after I stop it, the little arrow that allows me to select "Debug Cell" disappears. Tried reverting back to previous versions, both vscode-jupyter and vscode-python extensions, nothing worked.

@p-i-
Copy link
Author

p-i- commented Aug 29, 2024

I've also bumped into that disappearing debug-cell option.

As I remember, closing and restarting VSCode shakes it loose.

I haven't been able to isolate a clean consistent minimal fail, so I haven't reported that oddity yet.

There are still quite a few quirks with running .ipynbs in VSCode. I wish they had someone on the team that uses .ipynbs a lot -- they would surely bump into these frustration points.

Or even a Discord where if some engineer hits such a problem, a core-dev could remote-inspect their system over screenlink. I'd be more than happy to allow a core-dev to dig around in my box if it would lead to a seamless UX.

@edervishaj
Copy link

This is not the only issue I face. After stopping the debugger (because it does not stop) and relaunching it, I get the error "Couldn't find a debug adapter for debug type python". This started occurring after the last update of VSCode/Python extension. I tried downgrading everything, the problem persists.

@p-i-
Copy link
Author

p-i- commented Sep 1, 2024

@edervishaj Did you try deleting and re-creating your Python .venv? It might be possible that it is corrupted somehow.

@edervishaj
Copy link

@edervishaj Did you try deleting and re-creating your Python .venv? It might be possible that it is corrupted somehow.

I created a new environment altogether, did not help at all. The debugger stops but after the first step over it throws the above error.

@DonJayamanne
Copy link
Contributor

After toggling this setting, I decided to inspect my User/Settings.json so that I could copy down the exact key for this setting, and was surprised to find that the setting isn't getting written to that file. I doubt this is connected to the original issue. But I am curious as to why I can't find this setting. I just checked again today and it is still not there.

@p-i- Please can you create a separate issue for this, then we can close this.
Also, when creating a new issue, please can you create the issue in the VS Code repo, as thats un-related to Jupyter extension (its a functionality provided by VS Code itself)

This is not the only issue I face. After stopping the debugger (because it does not stop) and relaunching it, I get the error "Couldn't find a debug adapter for debug type python". This started occurring after the last update of VSCode/Python extension. I tried downgrading everything, the problem persists.

@edervishaj Please can you create a new issue and please do share the following logs in that new issue
Please could you enable logging as follows:

  • Open settings & go into Jupyter->Logging
  • Change the value to trace
  • Reload VS Code,
  • Attempt to repro the issue & then copy the output from the Jupyter output panel (use the command Jupyter: Show Output to get to the logs).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug notebook-debugging
Projects
None yet
Development

No branches or pull requests

3 participants