From d2da575c411ffc9728f2c3c31ecb3c73e9f679d6 Mon Sep 17 00:00:00 2001 From: konsti Date: Fri, 12 Apr 2024 17:06:38 +0200 Subject: [PATCH] Log hardlink failures (#3015) Inspired by https://github.com/astral-sh/uv/issues/2964, we now properly log hardlink failures, e.g. when the cache is a docker container but the venv is in a bind mount, e.g.: ``` DEBUG Failed to hardlink `/code/venv/uv/lib/python3.12/site-packages/asgiref-3.8.1.dist-info/WHEEL` to `/root/.cache/uv/archive-v0/nnpkKgUoM3LMxcNDmEKJQ/asgiref-3.8.1.dist-info/WHEEL`, attempting to copy files as a fallback ``` --- crates/install-wheel-rs/src/linker.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/install-wheel-rs/src/linker.rs b/crates/install-wheel-rs/src/linker.rs index 923270670..930c3fa3b 100644 --- a/crates/install-wheel-rs/src/linker.rs +++ b/crates/install-wheel-rs/src/linker.rs @@ -333,14 +333,17 @@ fn clone_recursive( if reflink::reflink(&from, &tempfile).is_ok() { fs::rename(&tempfile, to)?; } else { - debug!("Failed to clone {} to temporary location {} - attempting to copy files as a fallback", from.display(), tempfile.display()); + debug!( + "Failed to clone `{}` to temporary location `{}`, attempting to copy files as a fallback", + from.display(), + tempfile.display()); *attempt = Attempt::UseCopyFallback; fs::copy(&from, &to)?; } } } else { debug!( - "Failed to clone {} to {} - attempting to copy files as a fallback", + "Failed to clone `{}` to `{}`, attempting to copy files as a fallback", from.display(), to.display() ); @@ -463,10 +466,20 @@ fn hardlink_wheel_files( if fs::hard_link(path, &tempfile).is_ok() { fs_err::rename(&tempfile, &out_path)?; } else { + debug!( + "Failed to hardlink `{}` to `{}`, attempting to copy files as a fallback", + out_path.display(), + path.display() + ); fs::copy(path, &out_path)?; attempt = Attempt::UseCopyFallback; } } else { + debug!( + "Failed to hardlink `{}` to `{}`, attempting to copy files as a fallback", + out_path.display(), + path.display() + ); fs::copy(path, &out_path)?; attempt = Attempt::UseCopyFallback; }