Skip to content

Commit e5889cf

Browse files
committed
add canonical_home and compare against seen_dir
1 parent abc8d35 commit e5889cf

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/cargo/util/context/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,13 +1678,17 @@ impl GlobalContext {
16781678
if let Some(path) = self.get_file_path(&config_root, "config", true)? {
16791679
walk(&path)?;
16801680
}
1681-
seen_dir.insert(config_root);
1681+
1682+
let canonical_root = config_root.canonicalize().unwrap_or(config_root);
1683+
seen_dir.insert(canonical_root);
16821684
}
16831685

1686+
let canonical_home = home.canonicalize().unwrap_or(home.to_path_buf());
1687+
16841688
// Once we're done, also be sure to walk the home directory even if it's not
16851689
// in our history to be sure we pick up that standard location for
16861690
// information.
1687-
if !seen_dir.contains(home) {
1691+
if !seen_dir.contains(&canonical_home) && !seen_dir.contains(home) {
16881692
if let Some(path) = self.get_file_path(home, "config", true)? {
16891693
walk(&path)?;
16901694
}

tests/testsuite/config.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,7 +2591,7 @@ fn mixed_type_array() {
25912591
}
25922592

25932593
#[cargo_test]
2594-
fn config_symlink_home_duplicate_load_bug() {
2594+
fn config_symlink_home_duplicate_load() {
25952595
// Test that when CARGO_HOME is accessed via a symlink that points to a directory
25962596
// already in the config search path, the config file is not loaded twice.
25972597

@@ -2647,13 +2647,5 @@ rustdocflags = ["--default-theme=dark"]
26472647
p.cargo("doc")
26482648
.cwd(&project_in_b)
26492649
.env("CARGO_HOME", &cargo_home)
2650-
.with_status(101)
2651-
.with_stderr_data(str![[r#"
2652-
[DOCUMENTING] foo v0.1.0 ([ROOT]/foo/a/b/foo)
2653-
[ERROR] Option 'default-theme' given more than once
2654-
2655-
[ERROR] could not document `foo`
2656-
2657-
"#]])
26582650
.run();
26592651
}

0 commit comments

Comments
 (0)