From 0dbeb4cd3de5ae900834124eee09de8c5a34ac81 Mon Sep 17 00:00:00 2001 From: konsti Date: Fri, 6 Feb 2026 14:46:03 +0100 Subject: [PATCH] Don't fail on creation of `sdist-vX/.git` if it already exists (#17825) Step 1 of N for readonly cache support. Moves the error message for LLM sandboxes from `sdist-vX/.git` to: ``` error: Could not acquire lock Caused by: Could not create temporary file Caused by: Read-only file system (os error 30 at path "/home/konsti/.cache/uv/.tmpfvc4gV" ``` --- crates/uv-cache/src/lib.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/crates/uv-cache/src/lib.rs b/crates/uv-cache/src/lib.rs index 17a5497a5..b4a139106 100644 --- a/crates/uv-cache/src/lib.rs +++ b/crates/uv-cache/src/lib.rs @@ -445,10 +445,23 @@ impl Cache { // We have to put this below the gitignore. Otherwise, if the build backend uses the rust // ignore crate it will walk up to the top level .gitignore and ignore its python source // files. - fs_err::OpenOptions::new().create(true).write(true).open( - root.join(CacheBucket::SourceDistributions.to_str()) - .join(".git"), - )?; + let phony_git = root + .join(CacheBucket::SourceDistributions.to_str()) + .join(".git"); + match fs_err::OpenOptions::new() + .create(true) + .write(true) + .open(&phony_git) + { + Ok(_) => {} + // Handle read-only caches including sandboxed environments. + Err(err) if err.kind() == io::ErrorKind::ReadOnlyFilesystem => { + if !phony_git.exists() { + return Err(err); + } + } + Err(err) => return Err(err), + } Ok(()) }