Hello hello folks. I'm having small problem with sqldelight in compose when running in my mac. When I create a database and I run:
./gradlew runDistributable
it works just fine. But when I run
./gradlew packageDmg
and I run the generated app... I get the error:
opening db: 'database.db_1' Read-only file system
.
Did anyone else ever faced this problem?
o
Olivier Patry
09/20/2024, 12:26 PM
Where do you store the database file?
I guess the parent dir is something like the current working directory, maybe not writable in some context?
Works fine on my side relying on
System.getProperty("user.home")
then creating a dedicated directory for my app, like
.myApp/
in which I store the database file.
l
Leandro Borges Ferreira
09/20/2024, 12:35 PM
I see. In my case I'm simply letting sqldelight to create the database file with:
Copy code
val database: Database = DatabaseFactory.createDatabase(
DriverFactory(),
url = "jdbc:sqlite:database.db_1",
)
[...]
public fun createDatabase(
driverFactory: DriverFactory,
url: String = "jdbc:sqlite:"
): Database {
val driver = driverFactory.createDriver(url)
return Database.invoke(driver)
}
I think I probably need to change the
database.db_1
to a place with more permissions, like you said a directory dedicated for the app
Leandro Borges Ferreira
09/20/2024, 12:35 PM
thanks Olivier!
o
Olivier Patry
09/20/2024, 12:43 PM
I do pretty much the same, the only nuance is that I use an absolute file path