Skip to content

fix(ffi): Resolve PermissionDenied (OS Error 5) on Windows during build.rs fallback#2231

Open
Bwen wants to merge 1 commit intotursodatabase:mainfrom
Bwen:fix-windows-build-os-error-5
Open

fix(ffi): Resolve PermissionDenied (OS Error 5) on Windows during build.rs fallback#2231
Bwen wants to merge 1 commit intotursodatabase:mainfrom
Bwen:fix-windows-build-os-error-5

Conversation

@Bwen
Copy link
Copy Markdown

@Bwen Bwen commented Apr 23, 2026

Description

This PR fixes an issue where compiling libsql-ffi on Windows panics with PermissionDenied (OS Error 5).

Inside build.rs, the copy_with_cp function attempts to use cp -R, which naturally fails on Windows. It then falls back to std::fs::copy(). However, fs::copy() cannot copy directories on Windows—it throws PermissionDenied instead of InvalidInput. The previous error handler only caught ErrorKind::InvalidInput to trigger copy_dir_all, causing Windows builds to panic.

This fix extends the error handling to catch both InvalidInput and PermissionDenied error kinds, routing both to copy_dir_all which properly handles directory copying.

Changes

  • Modified copy_with_cp fallback logic in libsql-ffi/build.rs to catch both InvalidInput and PermissionDenied error kinds
  • Both error types now correctly route to copy_dir_all
  • Maintains backward compatibility with existing Unix-like behavior

Testing

This fix allows libsql-ffi to build successfully on Windows platforms without panicking during the copy operation.
libsql = { version = "0.9.30", features = ["encryption"] }

Note: This patch and PR description were generated with the assistance of AI to identify and resolve the Windows-specific build constraint.

@Bwen Bwen force-pushed the fix-windows-build-os-error-5 branch 2 times, most recently from f722e7b to 49a3b9e Compare April 23, 2026 08:16
…indows

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)
@Bwen Bwen force-pushed the fix-windows-build-os-error-5 branch from 49a3b9e to 23402e6 Compare April 23, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant