From 23402e68a38245ab3c1346a247f2e7338552cdd1 Mon Sep 17 00:00:00 2001 From: Bwen Egavas Date: Thu, 23 Apr 2026 03:28:50 -0400 Subject: [PATCH] fix(ffi): Handle PermissionDenied error in copy_with_cp fallback on Windows The copy_with_cp function in build.rs attempts to use `cp -R` which fails on Windows, then falls back to `std::fs::copy()`. However, `fs::copy()` cannot copy directories and throws PermissionDenied on Windows instead of InvalidInput. This commit extends the error handling to catch both InvalidInput and PermissionDenied error kinds, routing both to copy_dir_all which properly handles directory copying across all platforms. Fixes: Windows builds panicking with PermissionDenied (OS Error 5) --- libsql-ffi/build.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libsql-ffi/build.rs b/libsql-ffi/build.rs index ceda2a6794..4874ce56dc 100644 --- a/libsql-ffi/build.rs +++ b/libsql-ffi/build.rs @@ -89,7 +89,12 @@ fn copy_with_cp(from: impl AsRef, to: impl AsRef) -> io::Result<()> { Ok(status) if status.success() => Ok(()), _ => match fs::copy(from.as_ref(), to.as_ref()) { - Err(err) if err.kind() == io::ErrorKind::InvalidInput => copy_dir_all(from, to), + Err(err) + if err.kind() == io::ErrorKind::InvalidInput + || err.kind() == io::ErrorKind::PermissionDenied => + { + copy_dir_all(from, to) + } Ok(_) => Ok(()), Err(err) => Err(err), },