flycheck / flycheck-rust

Better Rust/Cargo support for Flycheck
GNU General Public License v3.0
121 stars 19 forks source link

change target directory #72

Closed wookietreiber closed 5 years ago

wookietreiber commented 5 years ago

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.

fmdkdd commented 5 years ago

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.

wookietreiber commented 5 years ago

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

fmdkdd commented 5 years ago

:+1: