Skip to content

Commit e55aad0

Browse files
committed
Auto merge of #14234 - epage:bad-path, r=weihanglo
fix(overrides): Don't warn on duplicate packages from using '..' ### What does this PR try to resolve? As part of #10752, I was changing the "duplicate package" warning to be like: ``` [WARNING] skipping duplicate package `a2 v0.5.0 ([ROOT]/foo/b/../a)`: [ROOT]/foo/b/../a/a2/Cargo.toml in favor of [ROOT]/foo/a/a2/Cargo.toml ``` and it showed that we were considering two paths to the same package to be duplicates. This suppresses that warning. ### How should we test and review this PR? ### Additional information
2 parents 0d67af0 + 3dd0173 commit e55aad0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/cargo/ops/resolve.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ use crate::util::cache_lock::CacheLockMode;
7878
use crate::util::errors::CargoResult;
7979
use crate::util::CanonicalUrl;
8080
use anyhow::Context as _;
81+
use cargo_util::paths;
8182
use std::collections::{HashMap, HashSet};
8283
use tracing::{debug, trace};
8384

@@ -454,7 +455,7 @@ pub fn add_overrides<'a>(
454455
// The path listed next to the string is the config file in which the
455456
// key was located, so we want to pop off the `.cargo/config` component
456457
// to get the directory containing the `.cargo` folder.
457-
(def.root(gctx).join(s), def)
458+
(paths::normalize_path(&def.root(gctx).join(s)), def)
458459
});
459460

460461
for (path, definition) in paths {

tests/testsuite/path.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -964,9 +964,8 @@ fn override_and_depend() {
964964
.cwd("b")
965965
.with_stderr_data(str![[r#"
966966
[LOCKING] 3 packages to latest compatible versions
967-
[WARNING] skipping duplicate package `a2` found at `[ROOT]/foo/[..]`
968-
[CHECKING] a2 v0.5.0 ([ROOT]/foo/[..])
969-
[CHECKING] a1 v0.5.0 ([ROOT]/foo/[..])
967+
[CHECKING] a2 v0.5.0 ([ROOT]/foo/a)
968+
[CHECKING] a1 v0.5.0 ([ROOT]/foo/a)
970969
[CHECKING] b v0.5.0 ([ROOT]/foo/b)
971970
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
972971
@@ -987,10 +986,10 @@ fn missing_path_dependency() {
987986
p.cargo("check")
988987
.with_status(101)
989988
.with_stderr_data(str![[r#"
990-
[ERROR] failed to update path override `[ROOT]/foo/../whoa-this-does-not-exist` (defined in `[ROOT]/foo/.cargo/config.toml`)
989+
[ERROR] failed to update path override `[ROOT]/whoa-this-does-not-exist` (defined in `[ROOT]/foo/.cargo/config.toml`)
991990
992991
Caused by:
993-
failed to read directory `[ROOT]/foo/../whoa-this-does-not-exist`
992+
failed to read directory `[ROOT]/whoa-this-does-not-exist`
994993
995994
Caused by:
996995
[NOT_FOUND]

0 commit comments

Comments
 (0)