rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.1k stars 178 forks source link

Working directory relative to current open file #363

Closed MagicRB closed 4 years ago

MagicRB commented 4 years ago

I find it weird that the cargo run and cargo build are run in the directory where the currently open file resides, I'd much prefer if cargo run specifically was run in the project root. My project expects it's data files to be located in the directory it's run in. I'm open to suggestions on how to remedy this issue in my code too. From what I gather this behavior comes from emacs' built-in compile command.

mookid commented 4 years ago

It is indeed what compile.el does. Also for reference see what https://github.com/kwrooijen/cargo.el/ does.

Can you show me an example of non-working code? FWIW, here is what I do in diffr: https://github.com/mookid/diffr/blob/f44f2306fe8744d0b11b037e82f0c7c0a75464f3/src/test_cli.rs#L60 CARGO_MANIFEST_DIR is supposed to be set by cargo run, and your code should depend on that rather than the cwd.

MagicRB commented 4 years ago

I'll switch to CARGO_MANIFEST_DIR if it's set then, thanks! you can close this if you want