#Using the Tauri SQL plugin, app fails to load SQLite file on Linux, while succeeding on Windows.

80 messages · Page 1 of 1 (latest)

glossy cypress
#

I don't really know why it's not working since I don't see any errors appearing in the console.

#

All I know is that it gets to the Database.load(res) line and then doesn't go further.

void skiff
#

is this true for tauri dev and tauri build? If only tauri build: binary, .deb, or appimage?

glossy cypress
#

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

void skiff
#

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

glossy cypress
#

Oh so you mean the file permissions in the resources folder is what makes this fail?

void skiff
#

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

glossy cypress
#

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
void skiff
#

alrighty, then first try to prepend sqlite:// in front of the path

glossy cypress
#

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?

void skiff
#

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)

glossy cypress
#

Ah, hmm

#

I thought it was necessary to resolve the resource first, no?

void skiff
#

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

#

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

glossy cypress
#

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?

void skiff
void skiff
#

that's what comes to mind rn

glossy cypress
#

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?

void skiff
#

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?

glossy cypress
#

Yes, works perfectly fine

void skiff
#

after installing the .msi?

glossy cypress
#

Only thing I haven't tried is development on linux

#

Yea

void skiff
#

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

glossy cypress
#

I should probably mention this is my first time compiling the app on Linux

#

So maybe I did something wrong. Hmm

#

(I used a simple docker container)

#

I can try again, building the app on Windows

void skiff
#

doesn't matter too much tbh. this stuff kinda triggers me so i'll add support for absolute paths today x)

glossy cypress
#

I assume this sql plugin isn't your favorite

#

But if you can that would be pretty damn cool ^^

void skiff
glossy cypress
#

I guess I'll just wait for you to add the support. ^^

void skiff
#

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)

glossy cypress
#

Nope, none

void skiff
#

thanks for checking, then i really have no idea what's happening

#

anywayyy, onto fixing it

glossy cypress
#

Great news ^^

#

Tysm for the help, appreciate it a lot

#

How do I solve

#

🤨

void skiff
#

by editing the thread tags :/

glossy cypress
#

Interesting feature.

void skiff
#

half baked like every other discord feature x)

void skiff
#

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)

glossy cypress
#

No worries, I don't know how to navigate github that well, where do I find it? @void skiff

void skiff
#

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)

glossy cypress
#

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```
void skiff
#

why don't i get that error locally wtf

#

alright that's fixed, try again after running cargo update in your src-tauri dir please

#

probably still doesn't work. so i'll test it after eating something

glossy cypress
#

Haha okay ^^

#

PeepoPog it no longer errors

glossy cypress
#

Yeah that did it, the db loads now ^^

#

Tyvm! pepoCheer