I set up the VS Code settings.json with the following configuration:
{
"rust-analyzer.checkOnSave": true,
"rust-analyzer.runnables.extraEnv": {
"RUST_BACKTRACE": "0"
},
"rust-analyzer.cargo.targetDir": true,
// "rust-analyzer.check.command": "clippy",
"rust-analyzer.check.overrideCommand": [
"cargo-clif",
"check",
"--workspace",
"--message-format=json",
"--all-targets"
]
}
This works, but when I run watchexec -- cargo-clif run on the project (it's a web server) to restart it on each change in the codebase, it stops with the following message:
Blocking waiting for file lock on build directory
If I use:
"rust-analyzer.check.command": "clippy",
it doesn't block.
How can I make cargo-clif check works in its own directory?
rust-analyzer does not support using a custom target directory when rust-analyzer.check.overrideCommand is used, however you can do it yourself. What rust-analyzer does when you set "rust-analyzer.cargo.targetDir": true is just passing --target-dir <old_target_dir>/rust-analyzer. You can just as well pass this argument manually to the command.
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