From 3dd017385031a0d2948735bce2d9645f35f33184 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 10 Jul 2024 17:06:22 -0500 Subject: [PATCH] fix(overrides): Don't warn on duplicate packages from using '..' 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. --- src/cargo/ops/resolve.rs | 3 ++- tests/testsuite/path.rs | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index e725211594e..c41f9efb447 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -78,6 +78,7 @@ use crate::util::cache_lock::CacheLockMode; use crate::util::errors::CargoResult; use crate::util::CanonicalUrl; use anyhow::Context as _; +use cargo_util::paths; use std::collections::{HashMap, HashSet}; use tracing::{debug, trace}; @@ -454,7 +455,7 @@ pub fn add_overrides<'a>( // The path listed next to the string is the config file in which the // key was located, so we want to pop off the `.cargo/config` component // to get the directory containing the `.cargo` folder. - (def.root(gctx).join(s), def) + (paths::normalize_path(&def.root(gctx).join(s)), def) }); for (path, definition) in paths { diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index f44409ead9e..81cc13a84ed 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -964,9 +964,8 @@ fn override_and_depend() { .cwd("b") .with_stderr_data(str![[r#" [LOCKING] 3 packages to latest compatible versions -[WARNING] skipping duplicate package `a2` found at `[ROOT]/foo/[..]` -[CHECKING] a2 v0.5.0 ([ROOT]/foo/[..]) -[CHECKING] a1 v0.5.0 ([ROOT]/foo/[..]) +[CHECKING] a2 v0.5.0 ([ROOT]/foo/a) +[CHECKING] a1 v0.5.0 ([ROOT]/foo/a) [CHECKING] b v0.5.0 ([ROOT]/foo/b) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -987,10 +986,10 @@ fn missing_path_dependency() { p.cargo("check") .with_status(101) .with_stderr_data(str![[r#" -[ERROR] failed to update path override `[ROOT]/foo/../whoa-this-does-not-exist` (defined in `[ROOT]/foo/.cargo/config.toml`) +[ERROR] failed to update path override `[ROOT]/whoa-this-does-not-exist` (defined in `[ROOT]/foo/.cargo/config.toml`) Caused by: - failed to read directory `[ROOT]/foo/../whoa-this-does-not-exist` + failed to read directory `[ROOT]/whoa-this-does-not-exist` Caused by: [NOT_FOUND]