Skip to content

Conversation

@fahdfady
Copy link

@fahdfady fahdfady commented Dec 2, 2025

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

@rustbot rustbot added the A-configuration Area: cargo config files and env vars label Dec 2, 2025
@epage
Copy link
Contributor

epage commented Dec 2, 2025

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 epage changed the title add canonical_home and compare against seen_dir Don't read the config file twice when $CARGO_HOME is a symlink Dec 2, 2025
@fahdfady fahdfady force-pushed the canonical-cargo-home branch from 513628f to 32bc65e Compare December 3, 2025 04:28
@fahdfady fahdfady marked this pull request as ready for review December 3, 2025 04:28
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 3, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 3, 2025

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

@fahdfady fahdfady force-pushed the canonical-cargo-home branch from 32bc65e to de20b86 Compare December 3, 2025 04:32
@fahdfady fahdfady force-pushed the canonical-cargo-home branch from 0038a81 to aa0376a Compare December 4, 2025 08:30
@rustbot rustbot added the A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. label Dec 4, 2025
@rustbot

This comment has been minimized.

@fahdfady fahdfady force-pushed the canonical-cargo-home branch 2 times, most recently from d196c27 to 7afa6bb Compare December 4, 2025 08:51
@fahdfady fahdfady force-pushed the canonical-cargo-home branch from 7afa6bb to 5163a92 Compare December 7, 2025 13:00
@rustbot rustbot added A-layout Area: target output directory layout, naming, and organization Command-clean labels Dec 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 7, 2025

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.

@fahdfady fahdfady force-pushed the canonical-cargo-home branch 3 times, most recently from 78f98d6 to c4cdbec Compare December 7, 2025 13:10
@fahdfady fahdfady requested a review from weihanglo December 7, 2025 14:44
@fahdfady fahdfady force-pushed the canonical-cargo-home branch from de316bf to dd6e815 Compare December 8, 2025 14:01
@fahdfady fahdfady force-pushed the canonical-cargo-home branch from dd6e815 to e5889cf Compare December 8, 2025 14:04
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working with us!

View changes since this review

@weihanglo weihanglo enabled auto-merge December 8, 2025 14:16
@weihanglo weihanglo added this pull request to the merge queue Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-configuration Area: cargo config files and env vars A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-layout Area: target output directory layout, naming, and organization Command-clean S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config file read twice when $CARGO_HOME is a symlink

4 participants