Skip to content

Commit fe917f2

Browse files
committed
fix(config): Don't double-warn about $CARGO_HOME/config
The core requirements for this bug are - You have a `$CARGO_HOME/.config` - Your project is inside of `$HOME` We have a check to make sure we don't double-walk `$CARGO/config` but that check is *after* we warn about there being no `.toml` extension. To fix this, we just need to move that check outside of the file lookup. This required changing the `seen` check from checking whether walked the config file to checking if we've walked the config dir. As we only have one file per directory, this should work.
1 parent 0b83e92 commit fe917f2

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/cargo/util/context/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,20 +1581,21 @@ impl GlobalContext {
15811581
where
15821582
F: FnMut(&Path) -> CargoResult<()>,
15831583
{
1584-
let mut seen = HashSet::new();
1584+
let mut seen_dir = HashSet::new();
15851585

15861586
for current in paths::ancestors(pwd, self.search_stop_path.as_deref()) {
1587-
if let Some(path) = self.get_file_path(&current.join(".cargo"), "config", true)? {
1587+
let config_root = current.join(".cargo");
1588+
if let Some(path) = self.get_file_path(&config_root, "config", true)? {
15881589
walk(&path)?;
1589-
seen.insert(path);
15901590
}
1591+
seen_dir.insert(config_root);
15911592
}
15921593

15931594
// Once we're done, also be sure to walk the home directory even if it's not
15941595
// in our history to be sure we pick up that standard location for
15951596
// information.
1596-
if let Some(path) = self.get_file_path(home, "config", true)? {
1597-
if !seen.contains(&path) {
1597+
if !seen_dir.contains(home) {
1598+
if let Some(path) = self.get_file_path(home, "config", true)? {
15981599
walk(&path)?;
15991600
}
16001601
}

tests/testsuite/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ f1 = 1
314314
.with_stderr_data(str![[r#"
315315
[WARNING] `[ROOT]/home/.cargo/config` is deprecated in favor of `config.toml`
316316
[NOTE] if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
317-
[WARNING] `[ROOT]/home/.cargo/config` is deprecated in favor of `config.toml`
318-
[NOTE] if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
319317
320318
"#]])
321319
.run();

0 commit comments

Comments
 (0)