blender-debugger-for-vscode icon indicating copy to clipboard operation
blender-debugger-for-vscode copied to clipboard

Debugger is attached but can't stop on breakpoints

Open SanzioCaroli opened this issue 1 year ago • 9 comments

OS: Windows 10

Add-on Version: 2.2.0

Blender Version: 3.2.1

VS Code Version: 1.69.2

VS Code Python Extension Version: v2022.10.1

  • debugpy version: 1.6.2

Paths listed by where python or the corresponding command: where python C:\Program Files\Blender Foundation\Blender 3.2\3.2\python\bin\python.exe C:\Program Files\FreeCAD 0.18\bin\python.exe C:\Users\carolisa\AppData\Local\Programs\Python\Python310\python.exe

Does VS Code / Visual Studio connect to the troubleshooting script? Yes

Python path/interpreter detected/selected by VS Code/Visual Studio: C:\Users\carolisa\AppData\Local\Programs\Python\Python310\python.exe

Blender and VSCode connect succesfully ( see picture attached ). But if I set a breakpoint on VsCode (on the print("test") statement) and I run the script with Alt-P on Blender, the breakpoint is ignored. Uploading Capture.JPG…

SanzioCaroli avatar Jul 22 '22 10:07 SanzioCaroli

Capture Maybe failed to upload in the message above...

SanzioCaroli avatar Jul 22 '22 10:07 SanzioCaroli

I found that if I move my python source code file on c:, everything works. It seems the debugger can't find the source code and looks on c:. How to specify the right path?

SanzioCaroli avatar Jul 22 '22 13:07 SanzioCaroli

Where was the script located and where did you move it to that it now works?

Also running scripts from Blender can be a problem. I remember some potential workarounds were discussed in #4, but I never got around to investigating.

AlansCodeLog avatar Jul 23 '22 18:07 AlansCodeLog

Not certain I was hitting the same issue, but after considerable head-scratching as to why the debugger couldn't match the source file I placed breakpoints in with the source of the addon, I decided to dig around VSCode for source path search settings (similar to Visual Studio) and found that you can specify the search path directly (vscode edit->preferences->settings then search for "debug path") (the add-on I wanted to debug was in c:\temp\addons...) image Restarted blender, reconnected the debugger and it worked as expected.

rlneumiller avatar Dec 07 '22 04:12 rlneumiller

What solved the issue for me was to change the auto-generated VSCode launch.json file. Specifically, "pathMappings.remoteRoot" should be set to "${workspaceFolder}" instead of the default ".". here is my complete launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "${workspaceFolder}" // I think this did the trick
                }
            ],
            "justMyCode": false
        }
    ]
}

DaseinPhaos avatar Jan 10 '23 09:01 DaseinPhaos

Change removeRoot to ${workspaceFolder} works for me! Thank you! 😸

aoirusann avatar Jan 30 '23 15:01 aoirusann

Had the same issue. The solution mentioned by DaseinPhaos worked for me too.

johnzero7 avatar Feb 12 '23 05:02 johnzero7

I will see if I can reproduce this and add it to the docs if so. Also @rlneumiller that is from a separate VS Code extension and not an internal setting of VS Code.

AlansCodeLog avatar Feb 15 '23 14:02 AlansCodeLog

I have the same problem and unfortunately, setting the path as @DaseinPhaos suggested did not work for me. Blender 3.65 and VSCode 1.88.1 with Python 3.10.11. Is anyone else still having problems with Breakpoints not triggering?

Praevelox1 avatar Apr 13 '24 19:04 Praevelox1