Unable to get VS Code to access other code while debugging - python-3.x

When I am debugging my python code it skips over code not written by me. I've set justmycode to false and I've tried updating request however, it won't accept any values except launch or attach and purpose is set to debug-test. Nothing seems to work.
My JSON file:
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode":false,
"purpose": ["debug-test"]
}
]
}
The message from the debugger(yes, I stepped in not over):
Frame skipped from debugging during step-in.
Note: may have been skipped because of "justMyCode" option (default == true). Try setting "justMyCode": false in the debug configuration (e.g., launch.json).
Sorry if this a stupid question I am a newbie and feeling totally over my head in my internship.
Literally this is my entire code. The message from the debugger appears when I try to step into execute().
pQuery=p.logquery()
pQuery.execute()

I had a similar problem just now and it suddenly started working when I set the justMyCode option to the end of the configuration without a comma at the end of the line.
So, not working:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Aktuelle Datei",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false,
}
]
}
And working example:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Aktuelle Datei",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
I cannot fathom why this is the case. If this works for you as well, please let me know.

The official docs on how to do it are here.
The OP was specifically adding a launch configuration for debugging tests. However, over here it's mentioned you should set "request": "test" for "for justMyCode to work with test debugging".
{
"name": "Python: Debug Tests",
"type": "python",
"request": "test",
"program": "${file}",
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": false
}
Which is not so clearly explained in the official docs... but worked for me.

Related

VScode node debugger throws Uncaught Error: write EPIPE

Whenever I try to run the debugger, I keep getting this error:
This is the debug configurations:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/server/bin/www",
"envFile": "${workspaceRoot}/server/.env"
}
]
}
---- Update ----
I am using VScode version 1.49.0
As #S.Clarke876 mentioned, it appears to be a bug in VS Code, that should be fixed in the next release. See: https://github.com/microsoft/vscode/issues/106484#issuecomment-691202789
You can work around the issue by adding "outputCapture": "std" to your launch.json file.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/server/bin/www",
"envFile": "${workspaceRoot}/server/.env",
"outputCapture": "std"
}
]
}
Worked for me! It only appeared to happen when the npm package debug attempted to write out to the console. I.e. console.log was fine.
Thanks again, #S.Clarke876! Only adding this answer as I nearly missed your comment.

Debugging Python in VS code not working

In am trying to debug my python script in VS Code but the debugger is not even starting. The blue bar keeps on loading after clicking the green play button and the bar below which was supposed to turn Orange doesn't change and is blue as it is.
What I tried?
1. Adding the path in launch.json file.
Here is my launch.json file.
{
// 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: Current File",
"type": "python",
"request": "launch",
"program": "${file}"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"pythonPath": "${config:python.pythonPath}"
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal",
"pythonPath": "${config:python.pythonPath}"
},
I have configured the path correctly in Windows advanced settings and in VS code workspace setting as well.
{
"python.pythonPath": "C:/Users/Admin/AppData/Local/Programs/Python/Python36-32/python.exe",
"code-runner.runInTerminal": true
}
If I try to run the debug in Python: Current File or Python: Terminal(Integrated), I get this error message:
C:\Users\Admin\Documents\PycharmProjects\Python_small_test\CSV_parser>cd c:\Users\Admin\Documents\PycharmProjects\Python_small_test\CSV_parser && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && C:/Users/Admin/AppData/Local/Programs/Python/Python36-32/python.exe C:\Users\Admin\.vscode\extensions\ms-python.python-2018.4.0\pythonFiles\PythonTools\visualstudio_py_launcher.py c:\Users\Admin\Documents\PycharmProjects\Python_small_test\CSV_parser 49947 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput c:\Users\Admin\Documents\PycharmProjects\Python_small_test\CSV_parser\test.py "
'cmd' is not recognized as an internal or external command,operable program or batch file.
And when I try to run it in Python: Terminal(external) , the IDE sits IDLE.
Any assistance is highly appreciated.
I figured it out.
I just had to add the path "C:\Windows\System32" in the path variable in environmental variables under Advanced System settings.

Debug jasmine tests written in typescript node in vs code

I have my unit tests written in jasmine and those are in typescript
// about.service.spec.ts
// say 4 to 5 test cases
// spec/support/jasmine.json
{
"spec_dir": "src/tests/",
"spec_files": ["**/*.spec.ts"],
"helpers": ["jasmine-helpers/**/*.ts"],
...
}
// launch.json - vscode file
{
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "Jasmine tests",
"preLaunchTask": "debuggertests",
}]
}
// tasks.json - vscode
{
"version": "2.0.0",
"tasks": [{
"label": "debuggertests",
"type": "npm",
"script": "test:unit",
"problemMatcher": []
}]
}
// package.json
// have to use jasmine-ts which is flavor over ts-node
"test:unit": "jasmine-ts JASMINE_CONFIG_PATH=spec/support/jasmine.json"
I have used this configuration to debug .spec.ts files in vscode but it did not fire debugger instead it run all tests and debugging started.
I have put a breakpoint in one of the test case of about.service.spec.ts but no breakpoint fired. Could anyone help me on setting up vscode debugging for jasmine tests?
In new jasmine-ts version, you have to include the jasmine.json to the args as this:
{
"type": "node",
"request": "launch",
"name": "Jasmine Current File",
"program": "${workspaceFolder}/node_modules/jasmine-ts/lib/index",
"args": ["--config=jasmine.json", "${file}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
To avoid this issue:
No specs found
Finished in 0.003 seconds
Incomplete: No specs found
Randomized with seed 60766 (jasmine --random=true --seed=60766)
Below configuration will debug current test file - please open the required test file in VS Code and start debugging with this configuration:
{
"type": "node",
"request": "launch",
"name": "Jasmine Current File",
"program": "${workspaceFolder}/node_modules/jasmine-ts/lib/index",
"args": ["${file}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}

Debugging an Electron app : Breakpoints not working ("Breakpoint ignored because generated code not found")

I've got a basic HelloWorld app based on the electron-hello-world project running on VSCode and able to launch a debug session and the app starts up fine.
I've got a breakpoint set on main.js but it appears to be greyed out with a message:
Breakpoint ignored because generated code not found (source map problem?)
Here is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"program": "${workspaceRoot}/main.js",
"port": 9222,
"sourceMaps": true,
"diagnosticLogging": true,
"outFiles": [
"${workspaceRoot}"
]
}
]
}
Any help would be much appreciated.
If your generated code is present in "${workspace Root}" then outFiles should be "outFiles": [ "${workspaceRoot}/*.js" ].
For more info link

Dynamic launch.json program javascript file

I'm running through a series of Pluralsight tutorials on NodeJS and have a directory with ~10 JS files in proving various concepts.
Every time I want to F5 debug my code, I have to ensure that my "program:" param is set to the current javascript file, which is pretty annoying.
Is there a way of dynamically doing this to save me needing to double check every 3 minutes?
If I simply take out the file name but leave "program:" I get the following error:
Cannot launch program 'C:\node\NodeJS Pluralsight\js'; setting the 'outFiles' attribute might help.
Here's my current launch.json:
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/js/currentFile.js", // What I'd like to change
"outFiles": [ "${workspaceRoot}/**/*.js" ]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 5858
}
Fixed this accidentally by rescoping my directory to a nested directory inside my project folder, that subsequently recreated the launch.json file. The configuration array is now:
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 5858
}
]
where ${file} has been used to represent the current file.

Resources