From 60f2ca338871fbadd369ec0e98e0c4428aa1eae7 Mon Sep 17 00:00:00 2001 From: konsti Date: Tue, 16 Sep 2025 19:49:08 +0200 Subject: [PATCH] Don't user display empty string for absolute path CWD (#15897) With the previous order an absolute path would become an empty string. --- crates/uv-fs/src/path.rs | 8 ++++---- crates/uv-workspace/src/dependency_groups.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/uv-fs/src/path.rs b/crates/uv-fs/src/path.rs index 4147a0cb3..d3993cd99 100644 --- a/crates/uv-fs/src/path.rs +++ b/crates/uv-fs/src/path.rs @@ -69,15 +69,15 @@ impl> Simplified for T { return path.display(); } + // Attempt to strip the current working directory, then the canonicalized current working + // directory, in case they differ. + let path = path.strip_prefix(CWD.simplified()).unwrap_or(path); + if path.as_os_str() == "" { // Avoid printing an empty string for the current directory return Path::new(".").display(); } - // Attempt to strip the current working directory, then the canonicalized current working - // directory, in case they differ. - let path = path.strip_prefix(CWD.simplified()).unwrap_or(path); - path.display() } diff --git a/crates/uv-workspace/src/dependency_groups.rs b/crates/uv-workspace/src/dependency_groups.rs index 4196ea6c5..b71921273 100644 --- a/crates/uv-workspace/src/dependency_groups.rs +++ b/crates/uv-workspace/src/dependency_groups.rs @@ -253,7 +253,7 @@ impl IntoIterator for FlatDependencyGroups { #[derive(Debug, Error)] #[error("{} has malformed dependency groups", if path.is_empty() && package.is_empty() { "Project".to_string() -} else if path.is_empty() { +} else if path.is_empty() || path == "." { format!("Project `{package}`") } else if package.is_empty() { format!("`{path}`")