Open AllanDaemon opened 1 month ago
Using the automaticly generated configuration for the cargo file above, when the workspace has only one place and it has the rust parts (like Cargo.toml
), it works:
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'uchoose'",
"cargo": {
"args": [
"build",
"--bin=uchoose",
"--package=uchoose"
],
"filter": {
"name": "uchoose",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
Using the same config where the rust part isn't in the root of the workspace, even when the cwd
is correctly set, has the same issue as before.
So the fact that I was writing the debug launch config from scratch wasn't the issue here, as the extension generated one has the same error.
A partial workaround is to pass --manifest-path=${workspaceFolder}/rust/Cargo.toml
as a Cargo arg:
"cargo": {
"args": [
"build",
"--manifest-path=${workspaceFolder}/rust/Cargo.toml",
...
HOWEVER, this won't pick up ${workspaceFolder}/rust/rust-toolchain.toml
(... which is a frustrating issue for me at the moment).
An uglier (but more effective) workaround is to use a wrapper script that first calls cd
and then calls cargo
.
Step 1: Write the wrapper script
#!/bin/bash
set -euo pipefail
cd "$1"
shift
exec "$HOME/.cargo/bin/cargo" "$@"
Step 2: Open User Settings
and change the lldb.cargo
setting to point at the wrapper script.
Step 3: Edit launch.json
so it passes the desired cwd
as the first arg to the wrapper script:
"configurations": [ {
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"${workspaceFolder}/rust",
"build",
...
],
...
My workaround was to create a separated workspace with the root on the rust dir just to run the debugger, and switch every time between the workspaces.
But the bug remains.
I seemed to fix the problem by moving cargo call into tasks.conf. But now, the debugger crashes after a few seconds after breakpoint stop, and I don't know how to fix that.
launch.json
{
"type": "lldb",
"name": "Tauri Development Debug",
"request": "launch",
"program": "${workspaceFolder}/src-tauri/target/debug/dream_spinner.exe",
"preLaunchTask": "rust: cargo build devel",
},
tasks.json
{
"type": "shell",
"command": "cargo build",
"problemMatcher": {
"base": "$rustc",
"fileLocation": [
"relative",
"${workspaceFolder}/src-tauri"
]
},
"label": "rust: cargo build devel",
"group": {
"kind": "build",
"isDefault": false
},
"options": {
"cwd": "${workspaceFolder}/src-tauri"
}
},
Context
OS: Ubuntu 24.04.1 LTS noble VSCode version:
CodeLLDB version: v1.10.0 Compiler: ❯
rustc 1.80.1 (3f5fd8dd4 2024-08-06)
cargo 1.80.1 (376290515 2024-07-16)
Debuggee: utility tool with GUI: https://github.com/AllanDaemon/uchoose/tree/oxidation
Issue
cwd
parameter isn't being used when launching a cargo debug run. It's using the workspace root.In the workspace root
/data/code/uchoose
, there is a folder calleduchoose-rs
where the rust code (including theCargo.toml
) is.In the
launcher.json
(using a hardcoded path to ensure it's not an env variable substitution problem):In the output, the first line says:
It's taking
/data/code/uchoose
(the root of workspace) instead of the defined "cwd"/data/code/uchoose/uchoose-rs/
.Verbose log
Output of terminal Output of output (with verbose logging)