Skip to content

libsql-ffi build failed on Windows #1657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wyhaya opened this issue Aug 10, 2024 · 8 comments · May be fixed by #2005
Open

libsql-ffi build failed on Windows #1657

wyhaya opened this issue Aug 10, 2024 · 8 comments · May be fixed by #2005

Comments

@wyhaya
Copy link
Contributor

wyhaya commented Aug 10, 2024

cargo new demo
cd demo
cargo add libsql
cargo check

Output

error: failed to run custom build command for `libsql-ffi v0.4.0`

Caused by:
  process didn't exit successfully: `C:\Users\...\target\debug\build\libsql-ffi-845dd5bc7ddd4d05\build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-changed=bundled/src/sqlite3.c

  --- stderr
  thread 'main' panicked at C:\Users\...\.cargo\registry\src\index.crates.io-6f17d22bba15001f\libsql-ffi-0.4.0\build.rs:48:10:
  called `Result::unwrap()` on an `Err` value: Error { kind: NotFound, message: "program not found" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Command::new("cp")
.arg("--no-preserve=mode,ownership")
.arg("-R")
.arg(format!("{dir}/{bindgen_rs_path}"))
.arg(&out_path)
.output()
.unwrap();

cp is sometimes not available on Windows.


Windows 11 rustc 1.80.0 libsql = "0.5.0"

@milen-denev
Copy link

I have the same issue

@matiassotomejias
Copy link

Hi, were you able to solve the problem? I have the same error

@wyhaya
Copy link
Contributor Author

wyhaya commented Sep 9, 2024

Hi, were you able to solve the problem? I have the same error

You can temporarily use the older version v0.4, which doesn't have this issue.

libsql = "0.4.0"

@milen-denev
Copy link

Hi, were you able to solve the problem? I have the same error

No. The only solution is to use libsql 0.4.0

@milen-denev
Copy link

The reason this occurs is because in the build.rs script the developers have put the Linux cp command for copying. I created my own copycat of cp, rust_cp. The repository has compiled binary, put this in any location you want on your windows system, and add Path environment variable, restart the system, and it should work.

image

@awakecoding
Copy link

I'm also hitting the same problem, calling "cp" directly was obviously going to break the Windows build, does that mean Windows support is not properly tested?

@Cammisuli
Copy link

I'm hoping that this can be fixed soon. Otherwise I'm gonna have to use a patched version, which is quite inconvenient ☹

@awakecoding
Copy link

It's actually fixed, but there hasn't been a release with the fix yet. I opened an issue about this because we'd really need the latest release to just build on Windows: #1969

allan2 added a commit to allan2/libsql that referenced this issue Mar 27, 2025
libsql-ffi build on Windows has been intermittently broken for a while due _build.rs_ calling `cp` which is not present on Windows.

Timeline:
- 2024-08-10: Issue tursodatabase#1657 was opened.
- 2024-11-14: tursodatabase#1791 was merged. First fix using `#[cfg(windows)]`.
- 2024-11-15: tursodatabase#1791 reverted in 9499c3c for breaking libsql-js on macOS.
- 2024-12-04: 9499c3c was reverted since tursodatabase#1791 was fine and did not cause the macOS problem. Windows build works again.
- 2025-03-17: da54c1b breaks Windows build.
- 2025-03-21: 0.9.1 is released with broken Windows build.
- 2025-03-27: This commit fixes the bug introduced in da54c1b.

This commit fixes a bug introduced by da54c1b. `Command::status()?` was propogating the error so the fallback, `fs::copy`, was never reached.
This is now fixed so libsql-ffi builds again on Windows.

Closes tursodatabase#1657
@allan2 allan2 linked a pull request Mar 27, 2025 that will close this issue
allan2 added a commit to allan2/libsql that referenced this issue Apr 9, 2025
libsql-ffi build on Windows has been intermittently broken for a while due _build.rs_ calling `cp` which is not present on Windows.

Timeline:
- 2024-08-10: Issue tursodatabase#1657 was opened.
- 2024-11-14: tursodatabase#1791 was merged. First fix using `#[cfg(windows)]`.
- 2024-11-15: tursodatabase#1791 reverted in 9499c3c for breaking libsql-js on macOS.
- 2024-12-04: 9499c3c was reverted since tursodatabase#1791 was fine and did not cause the macOS problem. Windows build works again.
- 2025-03-17: da54c1b breaks Windows build.
- 2025-03-21: 0.9.1 is released with broken Windows build.
- 2025-03-27: This commit fixes the bug introduced in da54c1b.

This commit fixes a bug introduced by da54c1b. `Command::status()?` was propogating the error so the fallback, `fs::copy`, was never reached.
This is now fixed so libsql-ffi builds again on Windows.

Closes tursodatabase#1657
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 a pull request may close this issue.

5 participants