-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cargo makes target-dir
path relative to user's home directory
#7843
Comments
Hm, this was a bit of an unexpected change from #7456. @alexcrichton do you have any thoughts on how this should behave? It looks like target_dir has been special since #2703 where it was interpreted as relative to cwd. I'm a little concerned about treating paths inconsistently (some config-relative, others cwd-relative). It's also questionable whether I wonder if it might be worthwhile to have a way for the user to control how relative paths are treated (like #6210)? For reference, the list of config vars with paths (which are treated as config-relative):
And program paths which have a special case to search PATH instead:
|
Oh dear this is indeed a bit of a confusing situation now! As of nowadays I think the current behavior is the best default, but I think it's a good idea to have more configurability here as well. It makes sense that you might want to configure globally a different name, and we could do something like |
I'd definitely be +1 on having a way to set a global project-relative directory for builds! Having it in Also, there's an additional issue of |
I'd like to quickly chime in that I got bitten by this today, especially I'd assumed setting |
I too was expecting it to be relative to the workspace root, since the default is relative to the workspace root. As @alexcrichton suggested in #7843 (comment), I think something like Right now it seems impossible to explicitly set the value to its default, which seems like a design smell. I.e., there should be some way to write
I’d be inclined to say that paths in a config file should generally be considered relative to that file. So, in ~/.cargo/config.toml, running
Maybe there are others, maybe |
I have a setting of
target-dir = ".cargo"
in~/.cargo/config
, to rename the default build directory. It has worked fine in the past, but now it seems that cargo takes thetarget-dir
path to mean realtive to my home directory, instead of relative to the project's directory.Right now my cargo (
rustc 1.40.0 (73528e339 2019-12-16
on Linux) with that option set, tries to build every project in a single directory:~/.cargo
. That of course creates problems. Also, runningcargo clean
in any projects deletes the main~/.cargo
directory!Using env variable
$CARGO_TARGET_DIR
to achieve what I want works just fine.Using
.cargo/config
inside my project also works! But, as soon as I executecargo clean
cargo deletes.cargo
directory in the project, so the setting is lost.Maybe this issue is related #7551?
The text was updated successfully, but these errors were encountered: