summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/crates/cargo-util
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/cargo/crates/cargo-util')
-rw-r--r--src/tools/cargo/crates/cargo-util/Cargo.toml2
-rw-r--r--src/tools/cargo/crates/cargo-util/src/paths.rs17
2 files changed, 16 insertions, 3 deletions
diff --git a/src/tools/cargo/crates/cargo-util/Cargo.toml b/src/tools/cargo/crates/cargo-util/Cargo.toml
index f01705fca..614581037 100644
--- a/src/tools/cargo/crates/cargo-util/Cargo.toml
+++ b/src/tools/cargo/crates/cargo-util/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "cargo-util"
-version = "0.2.4"
+version = "0.2.5"
edition = "2021"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/rust-lang/cargo"
diff --git a/src/tools/cargo/crates/cargo-util/src/paths.rs b/src/tools/cargo/crates/cargo-util/src/paths.rs
index 69df7a209..4a917821b 100644
--- a/src/tools/cargo/crates/cargo-util/src/paths.rs
+++ b/src/tools/cargo/crates/cargo-util/src/paths.rs
@@ -55,6 +55,8 @@ pub fn dylib_path_envvar() -> &'static str {
// penalty starting in 10.13. Cargo's testsuite ran more than twice as
// slow with it on CI.
"DYLD_FALLBACK_LIBRARY_PATH"
+ } else if cfg!(target_os = "aix") {
+ "LIBPATH"
} else {
"LD_LIBRARY_PATH"
}
@@ -411,11 +413,22 @@ fn _create_dir_all(p: &Path) -> Result<()> {
Ok(())
}
-/// Recursively remove all files and directories at the given directory.
+/// Equivalent to [`std::fs::remove_dir_all`] with better error messages.
///
/// This does *not* follow symlinks.
pub fn remove_dir_all<P: AsRef<Path>>(p: P) -> Result<()> {
- _remove_dir_all(p.as_ref())
+ _remove_dir_all(p.as_ref()).or_else(|prev_err| {
+ // `std::fs::remove_dir_all` is highly specialized for different platforms
+ // and may be more reliable than a simple walk. We try the walk first in
+ // order to report more detailed errors.
+ fs::remove_dir_all(p.as_ref()).with_context(|| {
+ format!(
+ "{:?}\n\nError: failed to remove directory `{}`",
+ prev_err,
+ p.as_ref().display(),
+ )
+ })
+ })
}
fn _remove_dir_all(p: &Path) -> Result<()> {