The default Rust Analyzer target directory is called target
which conflicts with the name used when cargo build
is run.
How can I change the target directory from target
to some other name?
The default Rust Analyzer target directory is called target
which conflicts with the name used when cargo build
is run.
How can I change the target directory from target
to some other name?
2
Answers
Go to Rust Analyzer Extension Settings, search for args.
Add the following two values:
--target-dir
target-rust-analyzer
If you use rust-analyzer extension of VS Code, you can specify target directory using extension settings.
Ctrl + ,
rust-analyzer cargo target dir
Rust-analyzer › Cargo: Target Dir
setting which is specifically for your use case.my_some_value
would mean that rust-analyzer files would be stored intarget/my_some_value
in workspace root. I myself set it torust-analyzer
so I can understand what it is.My VS Code
settings.json
:You probably should to keep rust-analyzer files inside
target
directory like me because this is supported better by tooling:target
directory is ignored by default template of.gitignore
/.hgignore
created bycargo new
so you don’t need to add rust-analyzer output directory manually.cargo clean
would clean both normal cargo output and rust-analyzer output which is often good. Also,cargo clean
almost never conflicts with rust-analyzer in my experience.