diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 1a9e3f1f031..b9b33690e45 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -297,7 +297,10 @@ fn rm_rf(path: &Path, config: &Config, progress: &mut dyn CleaningProgressBar) - let entry = entry?; progress.on_clean()?; if entry.file_type().is_dir() { - // `remove_dir_all` is used here due to https://github.com/rust-lang/cargo/issues/11441 + // The contents should have been removed by now, but sometimes a race condition is hit + // where other files have been added by the OS. `paths::remove_dir_all` also falls back + // to `std::fs::remove_dir_all`, which may be more reliable than a simple walk in + // platform-specific edge cases. paths::remove_dir_all(entry.path()) .with_context(|| "could not remove build directory")?; } else {