fix(ffi): Resolve PermissionDenied (OS Error 5) on Windows during build.rs fallback#2231
Open
Bwen wants to merge 1 commit intotursodatabase:mainfrom
Open
fix(ffi): Resolve PermissionDenied (OS Error 5) on Windows during build.rs fallback#2231Bwen wants to merge 1 commit intotursodatabase:mainfrom
Bwen wants to merge 1 commit intotursodatabase:mainfrom
Conversation
f722e7b to
49a3b9e
Compare
…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)
49a3b9e to
23402e6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue where compiling
libsql-ffion Windows panics withPermissionDenied (OS Error 5).Inside
build.rs, thecopy_with_cpfunction attempts to usecp -R, which naturally fails on Windows. It then falls back tostd::fs::copy(). However,fs::copy()cannot copy directories on Windows—it throwsPermissionDeniedinstead ofInvalidInput. The previous error handler only caughtErrorKind::InvalidInputto triggercopy_dir_all, causing Windows builds to panic.This fix extends the error handling to catch both
InvalidInputandPermissionDeniederror kinds, routing both tocopy_dir_allwhich properly handles directory copying.Changes
copy_with_cpfallback logic inlibsql-ffi/build.rsto catch bothInvalidInputandPermissionDeniederror kindscopy_dir_allTesting
This fix allows
libsql-ffito 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.