You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cli: npm CLI (1.19.3) crashes on shared opencode.db created by Desktop 2.0.32 — 'Database is not empty and has no session table' #56583
The standalone CLI installed from npm (opencode-ai, dist-tag latest = 1.19.3) crashes with Database is not empty and has no session table when run against the shared ~/.local/share/opencode/opencode.db created by OpenCode Desktop 2.0.32. Every CLI command fails until the user points XDG_DATA_HOME elsewhere. npm's registry has no 2.x releases at all (12,253 versions, none starting with "2."), so CLI-only users are stuck on the 1.x line with no actionable error.
Terminal: Unavailable (terminal environment variables are not set)
Shell: pwsh (PowerShell 7)
Install/channel: npm opencode-ai (latest = 1.19.3) + OpenCode Desktop auto-update (2.0.32) sharing the same data dir
Active plugins: none (global config only has mcp.servers.vercel)
Reproduction
Use a machine where OpenCode Desktop 2.0.32 has been running (shared opencode.db under ~/.local/share/opencode).
npm install -g opencode-ai (installs 1.19.3 per the latest dist-tag).
Run any storage-using command, e.g. opencode mcp list.
Expected Behavior
The CLI should detect that the data directory was created by a newer version and fail gracefully with an actionable message (e.g. "Data created by opencode 2.0.32 — update the CLI or point XDG_DATA_HOME to an isolated directory"), rather than attempting bundled migrations (CREATE TABLE project ...) and dying with a bare schema error.
Actual Behavior
v1.15.10: failed to run data migrations ... Failed to run the query 'CREATE TABLE project ...'
v1.19.3: Error: Unexpected error ... Database is not empty and has no session table
All CLI subcommands fail unconditionally.
The same DB works fine with the Desktop's bundled CLI (AppData/Local/Programs/@opencodedesktop/resources/opencode-cli.exe v2.0.32 → ✓ vercel connected), which confirms schema-version skew is the root cause.
Reproduces consistently (every invocation).
Additional Context
Isolated data dir ($env:XDG_DATA_HOME=<empty dir>; opencode mcp list) works fine on 1.19.3 — it only breaks against the newer shared DB.
opencode upgrade (npm channel) can never align, since npm has no 2.x release (npm view opencode-ai versions: none matching ^2\.; latest = 1.19.3). The dev/beta dist-tags point to 0.0.0-* snapshot builds.
Workarounds: use the Desktop's bundled CLI, or permanently isolated XDG_DATA_HOME.
Suggestion: either publish 2.x to npm (or a v2 dist-tag), and/or version-gate the data dir with a clear error telling users which channel to install from.
Thanks for the detailed report! I think this is a duplicate of #53221. That issue has the same Database is not empty and has no session table error, caused by a v1 build opening the shared opencode.db after v2 has migrated it (v2 renames the session table to session_v2). There it's the v1 Desktop and the v2 CLI; here it's the other way around, but the cause is the same.
One thing that should fix this for you: OpenCode v2 is on npm, under a different package name. opencode-ai is the v1 package (1.x only); v2 is published as @opencode/cli (it still installs the opencode command):
That keeps your CLI on the same version as Desktop 2.0.32, so both can use the same database. v1 only gets fixes for critical bugs, so the v1 CLI is unlikely to learn to handle a v2 database.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
Closing this as a duplicate of #53221, since there hasn't been a reply in the last day. Both issues have the same Database is not empty and has no session table error, caused by a v1 build opening the shared opencode.db after v2 has migrated it. Please follow #53221 for updates.
If you just want things working again: v2 is on npm as @opencode/cli (opencode-ai only has v1). Installing it puts your CLI on the same version as Desktop 2.0.32:
If your problem turns out to be different from #53221, or still happens with @opencode/cli, please comment here and we'll take another look. Thanks again for the detailed report!
Activity
opencode-agent commentedon Oct 17, 2026
Thanks for the detailed report! I think this is a duplicate of #53221. That issue has the same
Database is not empty and has no session tableerror, caused by a v1 build opening the sharedopencode.dbafter v2 has migrated it (v2 renames thesessiontable tosession_v2). There it's the v1 Desktop and the v2 CLI; here it's the other way around, but the cause is the same.Related issues, ordered by likelihood:
sessionandsession_v2#44028: stable and beta shareopencode.dbbut use incompatiblesession/session_v2tablesOne thing that should fix this for you: OpenCode v2 is on npm, under a different package name.
opencode-aiis the v1 package (1.x only); v2 is published as@opencode/cli(it still installs theopencodecommand):npm uninstall -g opencode-ai npm install -g @opencode/cli opencode --version # should print 2.xThat keeps your CLI on the same version as Desktop 2.0.32, so both can use the same database. v1 only gets fixes for critical bugs, so the v1 CLI is unlikely to learn to handle a v2 database.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
opencode-agent commentedon Oct 18, 2026
Closing this as a duplicate of #53221, since there hasn't been a reply in the last day. Both issues have the same
Database is not empty and has no session tableerror, caused by a v1 build opening the sharedopencode.dbafter v2 has migrated it. Please follow #53221 for updates.If you just want things working again: v2 is on npm as
@opencode/cli(opencode-aionly has v1). Installing it puts your CLI on the same version as Desktop 2.0.32:If your problem turns out to be different from #53221, or still happens with
@opencode/cli, please comment here and we'll take another look. Thanks again for the detailed report!