I am trying to debug a Rust program in VS Code, but I get an error:

After clicking OK, VS Code opens "settings.json":

I have these extensions installed:

My program is a simple "hello world" app.
Unfortunately VS Code can't debug Rust out of the box :( But no need to worry, just few steps of configuration will do the work :)
Install C/C++ extension if you are on windows and CodeLLDB if on OS X/Linux
Click Debug -> Add Configuration, a launch.json file should open, you need to change the program name here manually
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceRoot}/target/debug/foo.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true
},
{
"name": "(OSX) Launch",
"type": "lldb",
"request": "launch",
"program": "${workspaceRoot}/target/debug/foo",
"args": [],
"cwd": "${workspaceRoot}",
}
]
}
Make sure Allow setting breakpoints in any file is checkend under File -> Preferences -> Settings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With