Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Debugger not debugging #1364

Closed
DonJayamanne opened this issue Apr 16, 2019 · 17 comments
Closed

Debugger not debugging #1364

DonJayamanne opened this issue Apr 16, 2019 · 17 comments

Comments

@DonJayamanne
Copy link
Contributor

@JoanEliot commented on Mon Apr 15 2019

Environment data

  • VS Code version: 1.33.1
  • Extension version (available under the Extensions sidebar): 2019.3.6558
  • OS and version: Win 10 Pro 1809
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: ?--debugger fails on "hello.py"
  • launch.json: quoted below

Expected behaviour

Debugging: Stop on breakpoints, display variables, permit stepwise execution

Actual behaviour

Either (a, yesterday) program execution hangs/nothing happens--debug toolbar appears but the only button that works is the stop button; or (b, today) program executes to completion successfully, without stopping at breakpoint. No variables appear in the sidebar in either case, but the status bar does flash orange in scenario b, not in a. Difference between (a) and (b) may be due to installing 1.33.1 in the interval--not sure when I updated from 1.33.0. (No problems evident to me running code without debugging/via 'Run Code.')

When I was last active in VSC and the Python extension, about a year ago everything worked fine. Same computer but of course Windows, Python, VSC and the extension have all had updates.

Steps to reproduce:

Follow tutorial at https://code.visualstudio.com/docs/python/python-tutorial#_configure-and-run-the-debugger (and preceding on same page).

  1. Enter and save as 'hello.py' the following 2-liner:

msg = "Hello World"
print(msg)

  1. Set breakpoint on line 1 and/or line 2.

  2. Press F5.

  3. Watch screen. Status bar flashes orange very briefly (no changes visible in sidebar), then "Hello World" appears in terminal.


launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"logToFile": true
}
]
}

Logs

Terminal output:
PS I:\Programming\Python3.Code> cd 'i:\Programming\Python3.Code'; ${env:PYTHONIOENCODING}='UTF-8'; ${env:PYTHONUNBUFFERED}='1'; & 'I:\Programming\Python3\python.exe' 'i:\PortableApps\VSC 1.33.1\data\extensions\ms-python.python-2019.3.6558\pythonFiles\ptvsd_launcher.py' '--default' '--client' '--host' 'localhost' '--port' '63065' 'i:\Programmi> cd 'i:\Programming\Python3.Code'; ${env:PYTHONIOENCODING}='UTF-8'; ${env:PYTHONUNBUFFERED}='1'; & 'I:\Programming\Python3\python.exe' 'i:\PortableApps\VSC 1.33.1\data\extensions\ms-python.python-2019.3.6558\pythonFiles\ptvsd_launcher.py' '--default' '--client' '--host' 'localhost' '--port' '63100' 'i:\Programming\Python3_Code\hello.py'
Hello World

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Jedi Python language engine.
##########Linting Output - pylint##########

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging):

No output under Console. Can't find Enable source map support... setting.

Debugger logs (via launch.json LogToFile

[2019-04-15 23:00:02.209] [exthost] [info] extension host started
[2019-04-15 23:00:02.231] [exthost] [info] ExtensionService#_doActivateExtension vscode.python {"startup":false,"activationEvent":"onLanguage:python"}
[2019-04-15 23:00:02.231] [exthost] [info] ExtensionService#loadCommonJSModule i:\PortableApps\VSC 1.33.1\resources\app\extensions\python\out\pythonMain
[2019-04-15 23:00:02.233] [exthost] [info] ExtensionService#_doActivateExtension ms-python.python {"startup":false,"activationEvent":"onLanguage:python"}
[2019-04-15 23:00:02.233] [exthost] [info] ExtensionService#loadCommonJSModule I:\PortableApps\VSC 1.33.1\data\extensions\ms-python.python-2019.3.6558\out\client\extension
[2019-04-15 23:00:02.358] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch {"startup":true,"activationEvent":""}
[2019-04-15 23:00:02.358] [exthost] [info] ExtensionService#loadCommonJSModule i:\PortableApps\VSC 1.33.1\resources\app\extensions\debug-auto-launch\dist\extension
[2019-04-15 23:00:02.364] [exthost] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"activationEvent":"
"}
[2019-04-15 23:00:02.364] [exthost] [info] ExtensionService#loadCommonJSModule i:\PortableApps\VSC 1.33.1\resources\app\extensions\emmet\dist\extension
[2019-04-15 23:00:02.368] [exthost] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"activationEvent":""}
[2019-04-15 23:00:02.368] [exthost] [info] ExtensionService#loadCommonJSModule i:\PortableApps\VSC 1.33.1\resources\app\extensions\git\dist\main
[2019-04-15 23:00:02.415] [exthost] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"activationEvent":"
"}
[2019-04-15 23:00:02.415] [exthost] [info] ExtensionService#loadCommonJSModule i:\PortableApps\VSC 1.33.1\resources\app\extensions\merge-conflict\dist\extension
[2019-04-15 23:00:02.418] [exthost] [info] ExtensionService#_doActivateExtension alefragnani.Bookmarks {"startup":true,"activationEvent":""}
[2019-04-15 23:00:02.418] [exthost] [info] ExtensionService#loadCommonJSModule I:\PortableApps\VSC 1.33.1\data\extensions\alefragnani.bookmarks-10.4.3\dist\extension
[2019-04-15 23:00:02.420] [exthost] [info] ExtensionService#_doActivateExtension alefragnani.numbered-bookmarks {"startup":true,"activationEvent":"
"}
[2019-04-15 23:00:02.420] [exthost] [info] ExtensionService#loadCommonJSModule I:\PortableApps\VSC 1.33.1\data\extensions\alefragnani.numbered-bookmarks-6.2.0\dist\extension
[2019-04-15 23:00:02.422] [exthost] [info] eager extensions activated
[2019-04-15 23:00:11.616] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-server-ready {"startup":false,"activationEvent":"onDebugResolve"}
[2019-04-15 23:00:11.616] [exthost] [info] ExtensionService#loadCommonJSModule i:\PortableApps\VSC 1.33.1\resources\app\extensions\debug-server-ready\dist\extension

3-Git.log has

fatal: not a git repository (or any of the parent directories): .git

@karthiknadig
Copy link
Member

@JoanEliot Can you check and make sure you have only one python extension (ms-python.python) in the extensions directory?
%USERPROFILE%\.vscode\extensions

If so, can you check the python extension folder for log files?

@JoanEliot
Copy link

@karthiknadig There's only one python extension in the extensions folder, though I recall removing an empty folder with an old version number yesterday or maybe the day before, when I was trying to fix the problem myself.

One point to add is that I am running VSC in "portable mode" per the official instructions on doing so--again, that worked fine in the past--so my extensions are in a subfolder of VSC itself. Yesterday I tried installing it the regular way, with the extensions located in %USERPROFILE%.vscode\extensions, and got exactly the same results. I just checked and that location likewise has only one copy of the python extension.

Anywhere, here's the log file from the extensions folder for the run I just made (same behavior in VSC as described above).

5:01:46 PM, 4/16/2019
Started @ Tue Apr 16 2019 17:01:46 GMT-0700 (Pacific Daylight Time)
From Client:
Content-Length: 313

{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"},"type":"request","seq":1}
To Client:
Content-Length: 761

{"seq":1,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsExceptionInfoRequest":true,"supportsConfigurationDoneRequest":true,"supportsDelayedStackTraceLoading":true,"supportsConditionalBreakpoints":true,"supportsSetVariable":true,"supportsExceptionOptions":true,"supportsGotoTargetsRequest":true,"supportsEvaluateForHovers":true,"supportsModulesRequest":true,"supportsValueFormattingOptions":true,"supportsHitConditionalBreakpoints":true,"supportsSetExpression":true,"supportsLogPoints":true,"supportTerminateDebuggee":true,"supportsCompletionsRequest":true,"exceptionBreakpointFilters":[{"filter":"raised","label":"Raised Exceptions","default":false},{"filter":"uncaught","label":"Uncaught Exceptions","default":true}]}}
From Client:
Content-Length: 628

{"command":"launch","arguments":{"name":"Python: Current File (Integrated Terminal)","type":"python","request":"launch","program":"i:\Programming\Python3\_Code\hello.py","console":"integratedTerminal","logToFile":true,"pythonPath":"I:\Programming\Python3\python.exe","cwd":"i:\Programming\Python3\.Code","envFile":"i:\Programming\Python3\.Code\.env","stopOnEntry":false,"showReturnValue":false,"internalConsoleOptions":"neverOpen","debugOptions":["RedirectOutput","FixFilePathCase"],"workspaceFolder":"i:\Programming\Python3\.Code","__sessionId":"ef6cd016-20d2-470d-9436-07d02d67be78"},"type":"request","seq":2}
To Client:
Content-Length: 479

{"command":"runInTerminal","arguments":{"kind":"integrated","title":"Python Debug Console","cwd":"i:\Programming\Python3\.Code","args":["I:\Programming\Python3\python.exe","i:\PortableApps\VSC 1.33.1\data\extensions\ms-python.python-2019.3.6558\pythonFiles\ptvsd_launcher.py","--default","--client","--host","localhost","--port","58469","i:\Programming\Python3\_Code\hello.py"],"env":{"PYTHONIOENCODING":"UTF-8","PYTHONUNBUFFERED":"1"}},"type":"request","seq":2}
From Client:
Content-Length: 116

{"type":"response","seq":3,"command":"runInTerminal","request_seq":2,"success":true,"body":{"shellProcessId":12672}}
To Client:
Content-Length: 628

To Client:
{"command":"launch","arguments":{"name":"Python: Current File (Integrated Terminal)","type":"python","request":"launch","program":"i:\Programming\Python3\_Code\hello.py","console":"integratedTerminal","logToFile":true,"pythonPath":"I:\Programming\Python3\python.exe","cwd":"i:\Programming\Python3\.Code","envFile":"i:\Programming\Python3\.Code\.env","stopOnEntry":false,"showReturnValue":false,"internalConsoleOptions":"neverOpen","debugOptions":["RedirectOutput","FixFilePathCase"],"workspaceFolder":"i:\Programming\Python3\.Code","__sessionId":"ef6cd016-20d2-470d-9436-07d02d67be78"},"type":"request","seq":2}
To Client:
Content-Length: 313

To Client:
{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"python","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"},"type":"request","seq":1}
To Client:
Content-Length: 130

{"type": "event", "seq": 0, "event": "output", "body": {"category": "telemetry", "output": "ptvsd", "data": {"version": "4.2.7"}}}Content-Length: 113

{"type": "response", "seq": 1, "request_seq": 2, "success": true, "command": "launch", "message": "", "body": {}}Content-Length: 865

{"type": "response", "seq": 2, "request_seq": 1, "success": true, "command": "initialize", "message": "", "body": {"supportsCompletionsRequest": true, "supportsConditionalBreakpoints": true, "supportsConfigurationDoneRequest": true, "supportsDebuggerProperties": true, "supportsDelayedStackTraceLoading": true, "supportsEvaluateForHovers": true, "supportsExceptionInfoRequest": true, "supportsExceptionOptions": true, "supportsHitConditionalBreakpoints": true, "supportsLogPoints": true, "supportsModulesRequest": true, "supportsSetExpression": true, "supportsSetVariable": true, "supportsValueFormattingOptions": true, "supportTerminateDebuggee": true, "supportsGotoTargetsRequest": true, "exceptionBreakpointFilters": [{"filter": "raised", "label": "Raised Exceptions", "default": false}, {"filter": "uncaught", "label": "Uncaught Exceptions", "default": true}]}}Content-Length: 63

{"type": "event", "seq": 3, "event": "initialized", "body": {}}
From Client:
Content-Length: 209

{"command":"setBreakpoints","arguments":{"source":{"name":"hello.py","path":"i:\Programming\Python3\.Code\hello.py"},"lines":[1],"breakpoints":[{"line":1}],"sourceModified":false},"type":"request","seq":4}
From Client:
Content-Length: 209

{"command":"setBreakpoints","arguments":{"source":{"name":"hello.py","path":"i:\Programming\Python3\_Code\hello.py"},"lines":[1],"breakpoints":[{"line":1}],"sourceModified":false},"type":"request","seq":5}
From Client:
Content-Length: 235

{"command":"setBreakpoints","arguments":{"source":{"name":"MileageScraper 001.py","path":"i:\Programming\Python3\.Code\MileageScraper 001.py"},"lines":[1],"breakpoints":[{"line":1}],"sourceModified":false},"type":"request","seq":6}
To Client:
Content-Length: 176

To Client:
{"type": "response", "seq": 4, "request_seq": 6, "success": true, "command": "setBreakpoints", "message": "", "body": {"breakpoints": [{"id": 0, "verified": true, "line": 1}]}}Content-Length: 176

{"type": "response", "seq": 5, "request_seq": 5, "success": true, "command": "setBreakpoints", "message": "", "body": {"breakpoints": [{"id": 1, "verified": true, "line": 1}]}}Content-Length: 176

{"type": "response", "seq": 6, "request_seq": 4, "success": true, "command": "setBreakpoints", "message": "", "body": {"breakpoints": [{"id": 2, "verified": true, "line": 1}]}}
From Client:
Content-Length: 99

{"command":"setExceptionBreakpoints","arguments":{"filters":["uncaught"]},"type":"request","seq":7}
To Client:
Content-Length: 130

{"type": "response", "seq": 7, "request_seq": 7, "success": true, "command": "setExceptionBreakpoints", "message": "", "body": {}}
From Client:
Content-Length: 56

{"command":"configurationDone","type":"request","seq":8}
To Client:
Content-Length: 184

To Client:
{"type": "event", "seq": 8, "event": "process", "body": {"name": "i:\Programming\Python3\_Code\hello.py", "systemProcessId": 7944, "isLocalProcess": true, "startMethod": "launch"}}
To Client:
Content-Length: 124

{"type": "response", "seq": 9, "request_seq": 8, "success": true, "command": "configurationDone", "message": "", "body": {}}
From Client:
Content-Length: 46

{"command":"threads","type":"request","seq":9}
To Client:
Content-Length: 93

{"type": "event", "seq": 10, "event": "thread", "body": {"reason": "started", "threadId": 1}}
To Client:
Content-Length: 159

{"type": "response", "seq": 11, "request_seq": 9, "success": true, "command": "threads", "message": "", "body": {"threads": [{"id": 1, "name": "MainThread"}]}}
To Client:
Content-Length: 118

To Client:
{"type": "event", "seq": 12, "event": "output", "body": {"output": "Hello World", "category": "stdout", "source": {}}}
To Client:
Content-Length: 109

To Client:
{"type": "event", "seq": 13, "event": "output", "body": {"output": "\n", "category": "stdout", "source": {}}}
From Client:
Content-Length: 47

{"command":"threads","type":"request","seq":10}
To Client:
Content-Length: 129

{"type": "response", "seq": 14, "request_seq": 10, "success": true, "command": "threads", "message": "", "body": {"threads": []}}
To Client:
Content-Length: 72

{"type": "event", "seq": 15, "event": "exited", "body": {"exitCode": 0}}
onEventTerminated
To Client:
Content-Length: 63

{"type": "event", "seq": 16, "event": "terminated", "body": {}}
From Client:
Content-Length: 80

{"command":"disconnect","arguments":{"restart":false},"type":"request","seq":11}
onResponseDisconnect
To Client:
Content-Length: 119

{"type": "response", "seq": 17, "request_seq": 11, "success": true, "command": "disconnect", "message": "", "body": {}}
Socket Error
check and shutdown
shutdown
killing process
check and shutdown
Kill process now
Shutting down debug session
disposing

@int19h
Copy link
Contributor

int19h commented Apr 17, 2019

Note the lowercase i:\ in the various paths in the logs. Looks like it might be another manifestation of #1311?

@JoanEliot
Copy link

@int19h, @DonJayamanne, @karthiknadig: I note with appreciation the concern expressed for users in various comments in #1311. I'm unfamiliar with the configuration settings referred to in the workaround for that manifestation (having to do with localhost etc). If that workaround approach is likely or reasonably possibly to be helpful for me, I would very much appreciate guidance in how to apply it, ideally in step-by-step, for-boneheads form. I settled on VSC as my editor/development environment last year--still using it to write bits of Lilypond/Scheme, HTML, and what not--so I am hopeful here. I do lean on the debugging services a lot, so if the workaround isn't relevant for me, please let me know so that I can find at least a temporary alternative tool for my current little Python project. (In that case, any recommendations for the easiest-to-get-up-to-speed-with Python IDE with basic debugging functionality?). Thank you.

@Biarys
Copy link

Biarys commented Apr 22, 2019

@JoanEliot you can add breakpoint() before/after the line you wanna debug. More on this: https://code.visualstudio.com/docs/python/debugging#_invoking-a-breakpoint-in-code

@Biarys
Copy link

Biarys commented Apr 25, 2019

Also, I solved the problem on Windows 10 by disabling case sensitivity for the project folder as in https://wpdev.uservoice.com/forums/266908-command-prompt-console-windows-subsystem-for-l/suggestions/34400512-recursive-file-case-sensitivity

Note that disabling sensitivity on one folder only affects that folder and not subfolders.
Note 2: I had the same issue using PyCharm and VSCode.

@JoanEliot
Copy link

@Biarys: Thanks for the input, but:

  • on my system, since VSC/python broke, breakpoints don't work period--the program executes all the way to completion regardless of any breakpoints.
  • fsutil shows my folders are already case insensitive.
    From what I can tell the problem appears to be due to path problems with VSC/the python extension/their "upstream" dependencies, and isn't due to case sensitivity issues with the file system.

@Red-Five
Copy link

Red-Five commented May 3, 2019

I can attach and see threads, but debugger not stopping at breakpoints.

Environment:
Google Cloud Code Extension version: 0.0.8
VSCode version: 1.33.1
OS: Linux

ptvsd Version: 4.2.8

@karthiknadig
Copy link
Member

@Red-Five If you want to debug files in /usr/local/lib/python2.7/dist-packages try setting justMyCode: false in your launch.json.

@Red-Five
Copy link

Red-Five commented May 3, 2019

@karthiknadig I removed that info to avoid confusion;

Remote docker location
/${APP}

Local dev location
/home/${USER}/${APP}

I forgot to mention remote app is running in docker on Google Kubernetes Engine if that's relevant.

@karthiknadig
Copy link
Member

karthiknadig commented May 3, 2019

@Red-Five Can you share your launch json configuration?
On a side note for development in docker you may also want to try this:
https://devblogs.microsoft.com/python/remote-python-development-in-visual-studio-code/

@Red-Five
Copy link

Red-Five commented May 3, 2019

@karthiknadig All details here: https://github.com/Red-Five/google-cloud-code-forseti-security/wiki

{
// 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": [
{
"type": "cloudcode",
"language": "Python",
"request": "attach",
"debugPort": 3000,
"localRoot": "/home/{USER_REDACTED}/forseti-security/google",
"remoteRoot": "/forseti-security/google",
"name": "Attach App on Kubernetes Cluster: Python",
"podSelector": {
"app": "forseti-server"
}
}
]
}

@karthiknadig
Copy link
Member

karthiknadig commented May 3, 2019

@Red-Five The debugger expects local and remote root mapping via path mappings. This is a typical attach configuration:

        {
            "name": "Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        },

The above "." for remote assumes that you want to map your workspace directory in VSCode to the working directory in the process where ptvsd is running. If that is not the mapping you want, then replace localRoot and remoteRoot as needed.

@fabioz
Copy link
Contributor

fabioz commented May 28, 2019

I think this issue is fixed now (there were some fixed issues related lowercase/uppercase drive letter which sometimes VSCode sent and the debugger didn't expect), so, I'm closing it. If it still doesn't work for you in the latest release, please reopen.

@fabioz fabioz closed this as completed May 28, 2019
@JoanEliot
Copy link

Update: The debugger still fails in just the way above detailed on my system (now running VSC 1.36.1 with Python ext 2019.6.24221). However, it turns out the failure is confined to files stored on my I: drive, a VeraCrypt encrypted virtual disk (https://www.veracrypt.fr/en/). The debugger works fine with the same code when the files are stored on other drives, including Cryptomator encrypted ones (https://cryptomator.org). I hope I can be excused for failing earlier to test the possibility that the encryption was involved, since everything had worked fine with my source files on the encrypted I: drive with earlier versions of VSC and the extension. Whatever changes in the extension and/or VSC that have caused the conflict with the VeraCrypt drive, it may be such an arcane problem that it's not worth tracking it down. I can work around it by moving my files, an inconvenience in terms of my workflow and backup system but not a big deal. I'm reporting the detail just in case it helps in some way.

@int19h
Copy link
Contributor

int19h commented Jul 11, 2019

@JoanEliot, I wonder if perhaps that particular virtual disk uses a case-sensitive filesystem? That should be fairly easy to check by intentionally miscasing files from command line.

On our end, we generally assume that all filesystems are case-insensitive on Win32. Which is almost always true in practice, but technically it does support case-sensitivity (and it can even be enabled on NTFS partitions). So it would be interesting to know if this is the problem.

@JoanEliot
Copy link

@int19h, the disk doesn't seem to implement case sensitivity, at the user level anyway. It behaves just like "regular" Windows in this regard, as far as I can tell--the case of each character in a file or folder name can be specified, and is retained and displayed in file listings, but case is ignored for file manipulation operations. For example, you can't create two files in the same folder whose names differ only in case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants