flycheck / flycheck-rust

Better Rust/Cargo support for Flycheck

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

change target directory

wookietreiber opened this issue · comments

Using cargo on the command line, I can change the target directory, e.g.:

cargo test --target-dir /tmp/project-name

Is it possible to change the target directory with flycheck-rust and if so how?


Note: I would like to do this to reduce the writes to my disk because it's an SSD and /tmp is a tmpfs.

Note: I do not want to set target-dir in Cargo.toml because I don't want to add this to version control.

It seems you can pass that option to cargo with an environment variable instead, so you could use a .dir-locals.el with:

((nil . ((eval . (setenv "CARGO_TARGET_DIR" "/tmp/project-name")))))

Or you could have a bit of elisp in your config that sets the environment variable for rust files.

Let me know if that works.

@fmdkdd Thanks, using .dir-locals.el works!

👍