Windows 10
I tried all the steps here and it didn't work.
I created a project LearnRust with the recommended command:
cargo new LearnRust --bin
I change directory (CD) to the LearnRust directory
I did the cargo run & cargo build, both work but F5 to debug the app fails with the error: Could not find Cargo.toml
even though the file is in the directory!
In the Rust VsCode instructions it says:
To start debugging, you will first need to install one of two language
extension with debugging support:
Microsoft C++ (ms-vscode.cpptools) – on Windows
Code LLDB (vadimcn.vscode-lldb) – on macOS/Linux
If you forget to install one of these extensions
rust-analyzer will provide a notification with links
to the VS Code Marketplace when you try to start a debug session.
The notification didn't appear for me and it's misleading that it says need to install one of two language extensions however since it also said If you forget to install one of these extensions I decided to install the "CodeLLDB" VsCode Extension by Vadim Chugunov as well as the C++.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/target/debug/LearnRust.exe",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "cargo build",
"stopOnEntry": false,
"sourceLanguages": ["rust"]
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cargo",
"command": "build",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo build"
}
]
}
F5 and it works:
Tip:
When you make code changes you need to cargo build
otherwise you end up debugging assembly code, not the .rs file.
rust-mosquitto
and nothing else. – Schwinn