diff --git a/crates/uv-fs/src/path.rs b/crates/uv-fs/src/path.rs index 4e5e8049eb25..11626f5c4afb 100644 --- a/crates/uv-fs/src/path.rs +++ b/crates/uv-fs/src/path.rs @@ -64,6 +64,11 @@ impl> Simplified for T { return path.display(); } + 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); @@ -85,6 +90,11 @@ impl> Simplified for T { .strip_prefix(base.as_ref()) .unwrap_or_else(|_| 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(); + } + path.display() }