#Using the Tauri SQL plugin, app fails to load SQLite file on Linux, while succeeding on Windows.
80 messages · Page 1 of 1 (latest)
All I know is that it gets to the Database.load(res) line and then doesn't go further.
is this true for tauri dev and tauri build? If only tauri build: binary, .deb, or appimage?
I've only been able to use tauri build so far. Also this is using a .deb file
I'll try to check in development mode
hmm, i could imagine that it doesn't like the read-only nature of the deb's install location 🤔
if that'd be the case you'd have to copy the db to a user data dir first and load it from there i guess
Oh so you mean the file permissions in the resources folder is what makes this fail?
well, maybe. The .deb is installed somewhre in /usr which basically means read-only for non-sudo apps, file permissions generally shouldn't matter here (but they could ig)
or maybe the file permissions prevent the .db from being executed in the first place and it's not about being able to actually write it/in its folder
I'm not an expert at Linux but couldn't I change the permissions to test this?
Maybe this is not the right way, but I ran the app with sudo (app), still does not load.
I think I found the issue, this displayed when running the command in the terminal.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
alrighty, then first try to prepend sqlite:// in front of the path
Okay, if I do that, then it fails to load on Windows. I'm sure I'm doing something wrong here.
The resolved resource returns this: \\?\C:\Users\durk\Documents\Project\App\src-tauri\target\debug\resources\data.db
Is it normal for that question mark to be there?
define "normal" x) the main issue here is that the plugin doesn't expect absolute paths
unless we changed that
but i also think sqlx indeed can't handle the question mark, even tho it's valid (many programs/libraries can't)
in this case yes. the plugin's design isn't really obvious. the intention here is to use Migrations to create the database dynamically on the user's system. therefore the plugin uses path's relative to https://tauri.app/v1/api/js/path/#appdir
a bit funny is why it worked on windows before adding sqlite://. It split of the C: prefix and added a sqlite: prefix itself
https://github.com/tauri-apps/plugins-workspace/blob/dev/plugins/sql/src/plugin.rs#L75-L89
sooo, ig the actual solution would be to let the plugin figure out if it's an absolute path and not try to make it relative to appDir in that case
Thing is I don't think I can create migrations since the db is supposed to be read only data
So, is there anything I can do to go about this?
which is valid, but something we didn't think about when we created the plugin.
- wait for me to fix the plugin
- use different paths depending on the os
- copy the db into the appDir before connecting to it
that's what comes to mind rn
I'm glad I pointed this out then ^^
For the second approach, for Windows I shouldn't put sqlite:// but on Linux how should the path look like? Without the question mark?
sqlite://<resolvedpath> which will look something like sqlite:///path/to/whatever (wanted to point out the triple slash) - so in theory you can just do sqlite://${resolvedPath}
actually
scratch that
did you ever try tauri build on windows?
Yes, works perfectly fine
after installing the .msi?
how tf does it work in the msi tho. doesn't make any sense to me
it still tries to make it relative to AppData/Roaming/bundle-id
I should probably mention this is my first time compiling the app on Linux
So maybe I did something wrong. 
(I used a simple docker container)
I can try again, building the app on Windows
doesn't matter too much tbh. this stuff kinda triggers me so i'll add support for absolute paths today x)

I assume this sql plugin isn't your favorite
But if you can that would be pretty damn cool ^^
what gave me away? 
Just tried building it again and yea, works completely fine with the DB. Just as an FYI
I guess I'll just wait for you to add the support. ^^
super weird
wait, can you check if there's a db somewhere in AppData/Roaming/bundleid/ ? (bundleid being whatever you set bundle.identifier to in tauri.conf)
Nope, none
thanks for checking, then i really have no idea what's happening
anywayyy, onto fixing it
by editing the thread tags :/
Interesting feature.
half baked like every other discord feature x)
sorry for the delay, finally pushed it to the sql/absolute-paths branch
didn't get to test it myself yet, soooo no promises
nvm there's an issue with the dir creation should be fixed (hopefully)
No worries, I don't know how to navigate github that well, where do I find it? @void skiff
https://github.com/tauri-apps/plugins-workspace/tree/sql/absolute-paths
in your cargo.toml file you just need to add branch = "sql/absolute-paths"
the branch name is a lie, i also added support for BaseDirectory similar to tauri's fs apis (but that needs the js api from git which isn't possible rn)
Oh I see, how easy
It does error, though
The create_dir_all does indeed fail, but the app doesn't actually start anymore for me
Not sure if you also have the error but
116 | let _ = create_dir_all(path.parent().unwrap_or(path)); // FIXME: Log this instead of ignoring it
| --------- ^^^^
| | |
| | expected `&std::path::Path`, found struct `PathBuf`
| | help: consider borrowing here: `&path`
| arguments to this function are incorrect
|
note: associated function defined here```
it no longer errors