From cbf772357d0a0b196a6372efd62f93e22b33c893 Mon Sep 17 00:00:00 2001 From: Lin Yihai Date: Fri, 13 Oct 2023 19:47:08 +0800 Subject: [PATCH] add detailed message when target folder path is invalid --- crates/cargo-util/src/paths.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/cargo-util/src/paths.rs b/crates/cargo-util/src/paths.rs index bf3ca3f82888..15bc16d2f5c1 100644 --- a/crates/cargo-util/src/paths.rs +++ b/crates/cargo-util/src/paths.rs @@ -694,7 +694,14 @@ pub fn create_dir_all_excluded_from_backups_atomic(p: impl AsRef) -> Resul // we can infer from it's another cargo process doing work. if let Err(e) = fs::rename(tempdir.path(), path) { if !path.exists() { - return Err(anyhow::Error::from(e)); + return Err(anyhow::Error::from(e)) + .with_context(|| { + format!( + "the path `{}` is invalid or broken symbolic link", + path.display() + ) + }) + .with_context(|| format!("failed to create directory `{}`", path.display())); } } Ok(())