Unset .cargo/config key for subdirectory #8112
Labels
A-configuration
Area: cargo config files and env vars
A-cross-compiling
Area: using --target flag for other platforms
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-needs-design
Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Describe the problem you are trying to solve
I'm writing a crate that sets a default target through the
build.target
key in the.cargo/config
file. I now want to create an utility crate for building the project in a subdirectory (as a replacement for a Makefile). So the file layout looks like this:The
utility
sub-crate should be executed on the host system. However, since the.cargo/config
file of the main project is in a parent directory, itsbuild.target
key applies to the sub-crate as well.Unfortunately, there seems to be no platform-independent way to reset the target to the host system again. I can pass
--target x86_64-unknown-linux-gnu
, but that won't work on other host systems such as Windows.Describe the solution you'd like
I can imagine different solutions to this problem:
.cargo/config
file. This way, thebuild.target
key could be unset for the subdirectory, so that it builds for the native target again..cargo/config
file.build.target
in a platform independent way. (I already proposed something like this for the--target
flag in Add--target HOST
alias for host target #6777.)Notes
One example that the ability to remove configuration keys is useful in practice is the
std::env::remove
function of the standard library. Like for.cargo/config
values, an environment variable set to the empty string""
is not equal to a variable that is not set. Therefore it makes sense to provide a way to go back to the "unset" state, which is especially useful if the variable was set by the parent program.The text was updated successfully, but these errors were encountered: