I was struggling with this issue for over a year but found the problem in my case.
VSCode python debugger will only recognize either CRLF or LF at the end of lines but not both. The debugger will appear to skip lines (but they are still executed) when there is a mix of the two in the file. This was happening in my case because I was adding lines of code while inside a debugging session and when I saved the file with the debugger session still live the end of line characters were different than the default in the file.
To solve it I simply had to change the line feed setting on right side of the bottom blue bar in VSCode from CRLF to LF back to CRLF and save the file.
Answer from WGee on Stack OverflowI'm new to using VS Code as I¡ve always used Eclipse IDE. I'm trying to debug my java file in which I've created a breakpoint, but the debugger just runs the code as if there wasn't such breakpoint..
I've seen some other people struggle with this, so here's my 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": "Java",
"type": "java",
"request": "launch",
"stopOnEntry": true,
"jdkPath": "${env:JAVA_HOME}/bin",
"cwd": "${fileDirname}",
"startupClass": "${fileBasenameNoExtension}",
"classpath": [
".",
"${fileDirname}"
]
},
{
"name": "Java Console App",
"type": "java",
"request": "launch",
"stopOnEntry": true,
"jdkPath": "${env:JAVA_HOME}/bin",
"cwd": "${fileDirname}",
"startupClass": "${fileBasenameNoExtension}",
"classpath": [
".",
"${fileDirname}"
],
"externalConsole": true
},
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Numeros",
"request": "launch",
"mainClass": "Numeros",
"projectName": "progra_4bad0bd0"
}
]
}Thanks in advance
I was struggling with this issue for over a year but found the problem in my case.
VSCode python debugger will only recognize either CRLF or LF at the end of lines but not both. The debugger will appear to skip lines (but they are still executed) when there is a mix of the two in the file. This was happening in my case because I was adding lines of code while inside a debugging session and when I saved the file with the debugger session still live the end of line characters were different than the default in the file.
To solve it I simply had to change the line feed setting on right side of the bottom blue bar in VSCode from CRLF to LF back to CRLF and save the file.
For making a log: The webserver is probably not allowed to write to c:/ - you probably want to use c:/temp (or whatever your temporary directory path is).
As for not stopping, it is possible that the paths for your webserver and locally on your hard drive are not the same, and you need to set up a "path mapping": https://github.com/felixfbecker/vscode-php-debug/blob/master/README.md#remote-host-debugging
Videos
Setting "justMyCode": false makes it stop at breakpoint:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true,
"justMyCode": false
},
]
}
If you're using a pytest-cov module you might also wanna have a look at pytest configuration settings note:
Note If you have the
pytest-covcoverage module installed, VS Code doesn't stop at breakpoints while debugging becausepytest-covis using the same technique to access the source code being run. To prevent this behavior, include--no-covinpytestArgswhen debugging tests, for example by adding"env": {"PYTEST_ADDOPTS": "--no-cov"}to your debug configuration.
See an example configuration file (launch.json) below:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"justMyCode": false,
"env": {"PYTEST_ADDOPTS": "--no-cov"}
}
]
}
I use VSCode with CodeLLDB and rust-analyzer plugins as my main Rust IDE. Everything works great and I absolutely reccomend this setup.
But a few weeks ago the debbuger started missing/skipping my breakpoints. When I click "Debug" the debugger and all breakpoints change from red dots to grey empty dots. It worked again for a while few days ago for a couple of days, but doesn't work now again.
So I'm wiriting this post on Reddit because I have why this happens, and even worse, how can I find out the reason of the problem. Google search gives basically useless results. The only clue how to look for a reason is this post where the author provides a debug output, but I don't know how I can find that output.
Therefore, I would really appreciate any advice and ideas what should I check and look for to find the issue and repair it.
For anyone wondering why I didn't look for an answer earlier: I also have an access to CLion, so in those rare cases I actually need debbuger and not println! I used that. But it annoys me that I need to change IDE to debug things.
It looks that there is an issue in vscode (Issue opened by on github [here][1]) . But for now, the workaround is to set the protocol in the configuration (launch.json) to "inspector". With this option, the breakpoints is now reached properly.
Also, change the "--debug=5858" in the "runtimeArgs" option to "--inspect=5858"
{
"type": "node",
"request": "launch",
"name": "Launch server with Nodemon",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
"runtimeArgs": [
"--inspect=5858"
],
"program": "${workspaceRoot}/src/server.ts",
"restart": true,
"port": 5858,
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"outFiles": ["${workspaceRoot}/build/**/*.js"],
"sourceMaps": true
},
Also, after that, if you have a flashing message error telling you:
Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858)
It means that your program is too short and that debugger has not enough time to break on your breakpoint. To resolve that, add a second runtime argument to option "runtimeArgs": "--debug-brk" and set too "stopOnEntry" option to true
The final configuration should looks like this:
{
"type": "node",
"request": "launch",
"name": "Launch server with Nodemon",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
"runtimeArgs": [
"--inspect=5858",
"--debug-brk"
],
"stopOnEntry": true,
"program": "${workspaceRoot}/src/server.ts",
"restart": true,
"port": 5858,
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"outFiles": ["${workspaceRoot}/build/**/*.js"],
"sourceMaps": true
}
It should break on the first line of your entry javascript file. Then you can press F5 and it will reach your own breakpoint.
If you don't want to press F5 each time you run your program, you can instead embed your main entry code inside a setTimeOut function with at least 1000 ms of timeout.
All these options will give enough of time to vscode to break on your breakpoints.
://github.com/Microsoft/vscode/issues/23900 "GitHub Issue"
@ManfredSteiner
I had this issue recently too. I guess you've tried to break just in the beginning of your entry file (main.ts). I've heard that we have this error message because the program is too short and terminates before the debugger can attach successfully. You have 2 solutions:
First, put your entry code inside a setTimeOut function with at least 1000 ms. It should give enough of time to debugger to attach to your program.
The second solution is to set to your launch.json the options: "stopOnEntry" to "true" and set the runtimeArgs option to ["--inspect=5858", "--debug-brk"].
Like this:
"configurations": [
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
"runtimeArgs": [
"--inspect=5858",
"--debug-brk"
],
"stopOnEntry": true,
"program": "${workspaceRoot}/src/server/main.ts",
"restart": true,
"port": 5858,
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"sourceMaps": true
}
]
It will break at the first line of your main.js and then, by pressing F5, you will be able to break on your own breakpoint in main.ts. If you don't want, each time you run your program, to press F5 until it reaches your breakpoint, I suggest you to use the first solution (Embed your main.ts entry code inside a setTimeOut function with a least 1000 ms). I hope it will help you
Try this configuration in your launch file:
{
"name": "Attach to Process",
"type": "node",
"protocol": "inspector",
"request": "attach",
"stopOnEntry": false,
"port": 5858,
"localRoot": "${workspaceRoot}",
"remoteRoot": "/somepath/myprojectroot",
"sourceMaps": true
}
Make sure the remoteRoot is correct path, otherwise it won't know where to look for the source files.
On the VSCode settings search for 'debug javascript use preview', and then disable it. It should now bound all breakpoints.
I use this configuration and work only if I insert this two line
// "stopOnEntry": true
// "justMyCode": false
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true,
"justMyCode": false
},
]
}
If you have upgraded your .Net Core SDK recently, just update netcoreappX.X
"program": "${workspaceFolder}/CommunityBot/bin/Debug/netcoreappX.X/CommunityBot.dll"
in launch.json file.
Check your .Net Core SDK version by dotnet --version