mirror of https://github.com/astral-sh/uv
Do not error when a virtual environment directory cannot be removed due to a busy error (#16394)
Closes https://github.com/astral-sh/uv/issues/16218 This occurs when using a mounted file system in Docker. We're almost always removing a virtual environment to replace it, and removing the parent directory isn't necessary for that.
This commit is contained in:
parent
491293362f
commit
17181fef07
|
|
@ -628,7 +628,21 @@ pub fn remove_virtualenv(location: &Path) -> Result<(), Error> {
|
|||
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
|
||||
Err(err) => return Err(err.into()),
|
||||
}
|
||||
fs_err::remove_dir_all(location)?;
|
||||
|
||||
// Remove the virtual environment directory itself
|
||||
match fs_err::remove_dir_all(location) {
|
||||
Ok(()) => {}
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
|
||||
// If the virtual environment is a mounted file system, e.g., in a Docker container, we
|
||||
// cannot delete it — but that doesn't need to be a fatal error
|
||||
Err(err) if err.kind() == io::ErrorKind::ResourceBusy => {
|
||||
debug!(
|
||||
"Skipping removal of `{}` directory due to {err}",
|
||||
location.display(),
|
||||
);
|
||||
}
|
||||
Err(err) => return Err(err.into()),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue