diff --git a/crates/install-wheel-rs/src/linker.rs b/crates/install-wheel-rs/src/linker.rs index 9226474f60a42..c4f3ee85f7672 100644 --- a/crates/install-wheel-rs/src/linker.rs +++ b/crates/install-wheel-rs/src/linker.rs @@ -296,10 +296,17 @@ fn clone_wheel_files( let mut count = 0usize; let mut attempt = Attempt::default(); - // On macOS, directly can be recursively copied with a single `clonefile` call. + // On macOS, directories can be recursively copied with a single `clonefile` call. // So we only need to iterate over the top-level of the directory, and copy each file or // subdirectory unless the subdirectory exists already in which case we'll need to recursively // merge its contents with the existing directory. + // + // On linux, we need to always reflink recursively, as `FICLONE` ioctl does not support directories. + // Also note, that reflink is only supported on certain filesystems (btrfs, xfs, ...), and only when + // it does not cross filesystem boundaries. + // + // On windows, we also always need to reflink recursively, as `FSCTL_DUPLICATE_EXTENTS_TO_FILE` ioctl + // is not supported on directories. Also, it is only supported on certain filesystems (ReFS, SMB, ...). for entry in fs::read_dir(wheel.as_ref())? { clone_recursive( site_packages.as_ref(), @@ -365,7 +372,7 @@ fn clone_recursive( debug!("Cloning {} to {}", from.display(), to.display()); - if cfg!(windows) && from.is_dir() { + if (cfg!(windows) || cfg!(target_os = "linux")) && from.is_dir() { // On Windows, reflinking directories is not supported, so we copy each file instead. fs::create_dir_all(&to)?; for entry in fs::read_dir(from)? {