Hello hello folks. I'm having small problem with s...
# compose-desktop
l
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
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
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
thanks Olivier!
o
I do pretty much the same, the only nuance is that I use an absolute file path
Copy code
JdbcSqliteDriver("jdbc:sqlite:${databaseFile.absolutePath}")
l
ah, okay! It worked here. Thanks!!
👍 1
👍🏻 1