-
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 uses configuration from $HOME/.cargo if $PWD is under $HOME even if $CARGO_HOME is set #11045
Comments
Ahh, I think I see what's happening here! Since my project is under I... don't know whether this is a bug? It feels extremely unexpected — I suspect most people have their projects under |
Although it doesn't appear for there to be any way to configure |
Which I suppose means this ties into #9769, and specifically: |
It's real weird, because this means that setting |
I see it like: Once As you mentioned, there is a meta issue #9769 and other issues similar to yours, so I am going to close this. Feel free to call out if you think this should stay open. Thank you! |
Yeah, I agree that this is "working as intended", though I'd still argue it's going to trip users up. I wonder if it's worth adding a warning when this situation is detected? This also had me thinking — does this mean that if I have a project under |
Hmm… It should be skipped and only loaded once. The current behaviour is somehow incorrect IMO. I believe the correct behaviour should be:
The current implementation seems not what I thought. If PR #10736 "Add |
Problem
I have an environment variable set using
[env]
in$HOME/.cargo/config.toml
. For a particular project, I use a dedicated$CARGO_HOME
with its ownconfig.toml
which sets that environment variable to a different value. However, I still observe that the value from my$HOME/.cargo/config.toml
is used.Steps
We can confirm that both
~/.cargo/config.toml
and$CARGO_HOME/config.toml
are loaded by adding an envvar just to the latter and seeing that it's set for build scripts and main code alike:Possible Solution(s)
No response
Notes
When I build and run with a modified version of
cargo
that printsConfig
, I get, in part:I'm surprised that anything at all from
$HOME/.cargo/config.toml
is used when$CARGO_HOME
is set. I would expect setting the latter to make Cargo forget all about$HOME/.cargo
. We should probably make that be the case, and ensure it's not just for[env]
.Version
The text was updated successfully, but these errors were encountered: