cargo icon indicating copy to clipboard operation
cargo copied to clipboard

Don't read the config file twice when $CARGO_HOME is a symlink

Open fahdfady opened this issue 1 month ago • 1 comments

What does this PR try to resolve?

Cargo should not load configuration twice if the config is symlinked

resolves #16206

How to test and review this PR?

Steps

on unix:

  1. mkdir -p a/b

  2. ln -s a c

  3. mkdir a/.cargo

  4. echo "[build]\nrustdocflags = [\"--default-theme=dark\"]" > a/.cargo/config.toml

  5. cd a/b

  6. CARGO_HOME=../../c/.cargo cargo doc

  7. notice (with strace or by having a project at a/b) that the config file is read twice and the build fails

fahdfady avatar Dec 02 '25 10:12 fahdfady

Note that a test should be added for this. We find it works best when a test is added in its own commit, showing the buggy behavior, and then put your fix on the commit after which will then update the test to show the fixed behavior.

epage avatar Dec 02 '25 13:12 epage

r? @weihanglo

rustbot has assigned @weihanglo. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Dec 03 '25 04:12 rustbot

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

rustbot avatar Dec 04 '25 08:12 rustbot

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

rustbot avatar Dec 07 '25 13:12 rustbot