Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.75k stars 106 forks source link

Crash with tauri at build time #361

Closed timothee-durand closed 11 months ago

timothee-durand commented 12 months ago

In tauri when I build the app (for MacOs M1) the compiler work but the app don't start and if i open the package and start it from the terminal it say :

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Connection(ConnectorError { user_facing_error: None, kind: QueryError(SqliteFailure(Error { code: CannotOpen, extended_code: 14 }, Some("unable to open database file: ../dev.db"))) })', src/main.rs:54:53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It seems like a permission issue because if i build it with the debug flag it works...

Can you help me with that or did i need to open an issue on tauri ?

Brendonovich commented 11 months ago

From the looks of things you're providing ../dev.db as your DB path. This won't fly, since the working directory when you launch the app will be .../YourApp/MacOS - the folder which contains the executable. Hence ../dev.db will resolve to ../YourApp, and I'm pretty sure that trying to create a db file inside an app would lead to an error like this. Instead, you'll want to customise the database location at runtime using the with_url option of the client builder, and set it to somewhere like /Library/Application Support/YourApp/database.db.

timothee-durand commented 11 months ago

Ok thanks a lot ! Its working !