Repository navigation
Description
Summary
The npm package opencode-ai still resolves to the v1 CLI (latest = 1.19.5) and is not deprecated. Once OpenCode Desktop v2 has started on the same machine, that CLI can no longer run any database command: every one of them dies with Database is not empty and has no session table, which reads like database corruption instead of a version mismatch. Deprecating opencode-ai (pointing at @opencode/cli) would stop this recurring trap at the source.
Environment
- opencode version:
1.19.5(npm[email protected], the npmlatesttag) andopencode v2.2.6(OpenCode Desktop,%APPDATA%\ai.opencode.desktop\cli\2.2.6-x64\opencode-cli.exe) - OS: Windows 11 Pro, 10.0.26200, win32 x64
- Terminal: OpenCode Desktop app; failures reproduced from PowerShell 7 and
cmd.exe - Shell:
C:\WINDOWS\system32\cmd.exe - Install/channel: npm global prefix
D:\npm-global([email protected]) + Desktop install - Active plugins: none (only
~/.config/opencode/AGENTS.mdandopencode.jsoncexist, nopluginsentry)
Reproduction
npm install -g opencode-ai— installs what npm still advertises aslatest(1.19.5), with no deprecation warning.- Install and use OpenCode Desktop 2.2.6. It creates/migrates the shared data directory
~/.local/share/opencode/opencode.db(tablesessionbecomessession_v2; the file contains 13 sessions at the time of writing). - From a terminal, run any of:
opencode statsopencode session listopencode db path
Expected Behavior
One of:
opencode-aiis marked deprecated on npm with a message pointing to@opencode/cli/anomalyco/tap/opencode-v2, so nobody installs the v1 CLI by accident; or- the v1 CLI detects that the database was migrated by a newer version and prints an actionable message, for example: "this data directory was migrated by OpenCode v2; run the v2 CLI (
@opencode/cli) or setOPENCODE_DATA_DIRto a separate directory".
Actual Behavior
$ opencode --version
1.19.5
$ opencode db path
Error: Unexpected error
Database is not empty and has no session table
$ opencode stats
Error: Unexpected error
Database is not empty and has no session table
$ opencode session list
Error: Unexpected error
Database is not empty and has no session table
opencode db path cannot even report which database it is opening, so there is no way to confirm the collision from the CLI side. opencode-cli.exe 2.2.6 reads the same file fine (opencode stats → 13 sessions, 519 steps, 35.3m tokens), so nothing is actually corrupted.
Additional Context
This is the same underlying failure as the closed reports #53221, #55731, #56583, #59727 and #61106 — all of which were closed with the answer "install the v2 CLI instead". The number of duplicates suggests the message users see is not the real problem; the real problem is that npm install -g opencode-ai is still a valid, undocumented-as-legacy install path that produces a permanently broken CLI on any machine that also runs Desktop v2.
Database state when the error occurs (read with sqlite3 in read-only mode, no writes):
tables: account, account_state, blob, blob_ref, control_account, credential, event,
event_sequence, instruction_blob, instruction_entry, instruction_state, job, kv,
migration, permission, project, project_directory, schedule, session_inbox,
session_message, session_part, session_v2, workspace, worktree
There is no session table, only session_v2, which is exactly what the v1 error message checks for.
If keeping the v1 package on npm is intentional, a deprecation notice alone would likely eliminate most of the duplicate reports, since npm install prints it at install time.
Activity
opencodejr commentedon Nov 10, 2026
Thanks for the thorough write-up and the read-only check of the database, @luckystation-cmd!
The CLI that fails here is
[email protected], which is OpenCode v1. v1 now only gets fixes for critical bugs, and this one has workarounds and loses no data (as you found, Desktop 2.2.6 reads the sameopencode.dbfine). So a v1-side change, like a clearer error when v1 finds a database that v2 has migrated, is unlikely to happen.Workarounds:
npm install -g @opencode/cli, which reads the data Desktop 2.x writes. Uninstallopencode-aifirst (or make sure the v2opencodecomes first on yourPATH) so the old 1.19.5 binary doesn't keep running.OPENCODE_DBor a separate data directory, so it never opens the file v2 migrated.I've passed your suggestion to deprecate the
opencode-ainpm package, with a pointer to@opencode/cli, on to the maintainers. That's their decision as part of releases, so I can't say whether or when it will happen.Related issues:
Database is not empty and has no session tableerror when a v1 build opens a database v2 has migratedsessionandsession_v2#44028: the broader problem of v1 and v2 sharing one data directory and splitting sessions betweensessionandsession_v2If you think this is critical, or you see the same problem with the v2 CLI, please reply here and say so.
opencodejr commentedon Nov 11, 2026
Closing this as not planned, since there was no reply in the past day. The failing CLI,
[email protected], is OpenCode v1, which now only gets critical fixes. This error has workarounds and loses no data: Desktop 2.2.6 still reads youropencode.dbfine.To get a working CLI, install the v2 package with
npm install -g @opencode/cli. Uninstallopencode-aifirst, or make sure the v2opencodecomes first on yourPATH. If you need v1 as well, give it its own database withOPENCODE_DBor a separate data directory.Deprecating
opencode-aion npm is up to the maintainers. Please follow #53221 for the underlying error. If you see this with the v2 CLI, or think it is critical, reply here or open a new issue.