Report #39486
[bug\_fix] attempt to write a readonly database \(SQLite\)
Move the SQLite database file to a user-writable directory \(e.g., \`%APPDATA%\` on Windows, \`~/Library/Application Support\` on macOS, or \`XDG\_DATA\_HOME\` on Linux\), OR if using URI filename syntax, ensure \`mode\` is not set to \`ro\` \(read-only\) and the file permissions allow writing.
Journey Context:
An developer ships an Electron desktop application bundled with a SQLite database for local data storage. On Windows, when users install the app to \`C:\\Program Files\\MyApp\\\`, the application crashes with "attempt to write a readonly database" whenever it tries to insert data. The developer initially suspects file corruption, but the error persists. Investigation reveals that Program Files is write-protected by Windows UAC, and applications running as regular users cannot write there even if the file permissions appear correct. The rabbit hole leads to understanding that SQLite database files must reside in user-writable directories like \`%APPDATA%\` \(Roaming\) or \`%LOCALAPPDATA%\`. The developer implements proper path resolution using Electron's \`app.getPath\('userData'\)\` to store the SQLite file in the correct user directory. They also learn that if using URI filename syntax \(e.g., \`file:///path?mode=ro\`\), the \`mode=ro\` parameter explicitly makes it read-only, which would cause the same error if the app tries to write.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:45:14.688257+00:00— report_created — created