Repository navigation
Description
Description
Summary
The latest public CLI release (1.19.5) fails at startup with Error: Database is not empty and has no session table because the shared database at ~/.local/share/opencode/opencode.db was migrated by the OpenCode desktop app's newer server build. The desktop app (2.2.5, auto-update channel latest) migrated the session table to session_v2 and applied migrations the released CLI does not know, so every new CLI process (TUI, opencode db, presumably anything that opens the DB) aborts.
Environment
- opencode version (CLI): 1.19.5 (
brew install opencode;which opencode→/opt/homebrew/bin/opencode -> ../Cellar/opencode/1.19.5/bin/opencode) - Desktop app: OpenCode 2.2.5 (auto-updater channel
latest,https://opencode.ai/update/api/latest/desktop/opencode/), running fine with a server that owns the DB - npm
opencode-aidist-taglatestis also 1.19.5 (published 2026-10-27);devsnapshot is 0.0.0-dev-202610280534 — both predate the migrations present in the DB - OS: Darwin coffee.localdomain 27.2.0 Kernel Version 27.2.0 arm64
- Shell: /bin/zsh
- Active plugins: None found (no
~/.config/opencode/opencode.json(c), no project plugins)
Reproduction
- Install the latest CLI (Homebrew 1.19.5, same as npm
latest). - Run the OpenCode desktop app (2.2.5), which starts its (newer) server and migrates the shared DB.
- In a terminal, run
opencodein any project directory — or anything that opens the DB, e.g.opencode db path.
Result every time:
Error: Database is not empty and has no session table
at <anonymous> (/$bunfs/root/chunk-bpahdg9h.js:2:832)
opencode db path fails the same way, so it is not project-specific. The desktop app and the already-running server are unaffected.
Expected Behavior
The latest CLI release should either open the shared database schema written by the current desktop app, or downgrade/discover an incompatible server/DB cleanly (e.g. attach to the healthy running service or surface a clear "CLI is older than the database schema; update required" message) instead of a generic "Unexpected error".
Actual Behavior
Startup checks in the CLI reject the database because the expected session table no longer exists:
Error: Database is not empty and has no session table
Additional Context
Findings from inspecting the DB (read-only checks + backup made, no modifications):
PRAGMA integrity_check→ok(the DB is not corrupt)- No
sessiontable; insteadsession_v2, plusworkspace,worktree,session_message,session_part,job,schedule, etc. migrationtable contains 59 entries, newest ids include20261029073502_session_time_busy,20261029165540_schedule_checks,20261030054400_job— newer than CLI 1.19.5's schema expectations- Diagnosis: version skew between the desktop app's bundled (newer) server and the latest publicly released CLI
Workarounds tried:
- Using the desktop app: works (its server understands the new schema)
- No working workaround found for the terminal CLI yet; giving the CLI its own database via
OPENCODE_DBwould work but loses the shared sessions
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot
No response
Operating System
MacOS 27.2
Terminal
cmux
Activity
opencodejr commentedon Nov 1, 2026
Thanks for the detailed report and the database checks! I think this is a duplicate of #53221.
The
opencodeformula in Homebrew core (andopencode-aion npm) is still OpenCode v1 (1.x). Your desktop app is v2 (2.2.5). Both use~/.local/share/opencode/opencode.db, and v2's migration renames thesessiontable tosession_v2. When the 1.19.5 CLI starts, it looks for a table namedsession, doesn't find one and stops with this error. Your database isn't corrupt, and your sessions are still there. v2 builds can read them.Possible duplicates and related issues, ordered from most to least likely:
opencode-aiCLI 1.19.3 together with Desktop 2.0.32To get the terminal CLI working with your shared sessions, replace the v1 formula with the v2 CLI:
brew uninstall opencode brew install anomalyco/tap/opencode-v2 # or: npm install -g @opencode/cliThe bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different, for example if a v2 (2.x) CLI shows the same error.
opencodejr commentedon Nov 2, 2026
Closing this as a duplicate of #53221, since there was no reply in the past day. That issue has the same
Database is not empty and has no session tableerror: a v1 build (here Homebrew'sopencode1.19.5) opens the sharedopencode.dbafter OpenCode v2 (Desktop 2.2.5) has renamedsessiontosession_v2. Your sessions are still in the database, and v2 builds can read them.To use the terminal CLI with your shared sessions, switch to the v2 CLI:
brew uninstall opencode brew install anomalyco/tap/opencode-v2 # or: npm install -g @opencode/cliIf a v2 (2.x) CLI shows the same error, please comment here with
opencode --versionand we can take another look.