Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(overrides): Don't warn on duplicate packages from using '..' #14234

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions tests/testsuite/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down