fix(installer): handle cleanup failures without panicking#2088
Merged
baszalmstra merged 2 commits intoconda:mainfrom Feb 22, 2026
Merged
fix(installer): handle cleanup failures without panicking#2088baszalmstra merged 2 commits intoconda:mainfrom
baszalmstra merged 2 commits intoconda:mainfrom
Conversation
Replace .unwrap() on tokio_fs::remove_dir_all in the sha256 and md5 hash-mismatch cleanup paths with a non-fatal tracing::warn!. The temp directory is already managed by a TempDir guard and will be removed on drop; a cleanup failure should not panic the retry loop and crash the installer. Signed-off-by: suhr25 <suhridmarwah07@gmail.com>
…anicking Replace .unwrap() on driver.remove_empty_directories() with .map_err(|e| InstallerError::UnlinkError(...))? so any filesystem error during empty-dir cleanup is returned as a structured InstallerError rather than crashing the process. Signed-off-by: suhr25 <suhridmarwah07@gmail.com>
Contributor
Author
|
Hi @wolfv @baszalmstra |
baszalmstra
approved these changes
Feb 22, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves robustness in the package installation pipeline by removing two instances where filesystem errors could cause unexpected process panics.
The first issue occurs in
crates/rattler_cache/src/package_cache/mod.rswithin the download retry loop. When a package fails its SHA-256 or MD5 hash validation, the code attempts to delete the partially extracted directory before retrying. This cleanup step previously used.unwrap(), meaning any transient OS-level failure (e.g., file locks, permission issues) would crash the process instead of allowing the retry logic to proceed.The second issue is in
crates/rattler/src/install/installer/mod.rsinsideexecute_transaction, the main function responsible for install, update, and removal operations. After unlinking packages, it callsremove_empty_directories(...)to clean up leftover directories. This also used.unwrap(), causing the entire transaction to panic on any cleanup failure rather than returning a structured error.These scenarios are particularly common on Windows systems, where background processes like antivirus scanners or indexing services can temporarily lock files.
This preserves retry behavior while avoiding unnecessary crashes.
2. Empty directory cleanup (installer)
The installer already defines
InstallerError::UnlinkErrorfor filesystem-related failures. The fix replaces.unwrap()with proper error propagation:driver .remove_empty_directories(&transaction.operations, transaction.unchanged_packages(), &prefix) .map_err(|e| InstallerError::UnlinkError("remove_empty_directories".to_string(), e))?;This ensures cleanup failures are surfaced to the caller instead of causing a panic.
Verification
get_or_fetch_from_url_with_retrycontinues to behave as expected, returningExtractError::HashMismatchand retrying appropriately.execute_transactionnow returnsInstallerError::UnlinkErroron cleanup failure, which is already handled by existing error flows.Notes