Skip to content

db: latest CLI (1.19.5) fails on DB migrated by desktop app ("Database is not empty and has no session table") #61106

Closed as duplicate

Description

@HirschleC

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-ai dist-tag latest is also 1.19.5 (published 2026-10-27); dev snapshot 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

  1. Install the latest CLI (Homebrew 1.19.5, same as npm latest).
  2. Run the OpenCode desktop app (2.2.5), which starts its (newer) server and migrates the shared DB.
  3. In a terminal, run opencode in 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 session table; instead session_v2, plus workspace, worktree, session_message, session_part, job, schedule, etc.
  • migration table contains 59 entries, newest ids include 20261029073502_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_DB would 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

  1. opencodejr commented on Nov 1, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report and the database checks! I think this is a duplicate of #53221.

    The opencode formula in Homebrew core (and opencode-ai on 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 the session table to session_v2. When the 1.19.5 CLI starts, it looks for a table named session, 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:

    To 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/cli

    The 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.

  2. opencodejr commented on Nov 2, 2026

    @opencodejr
    Contributor

    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 table error: a v1 build (here Homebrew's opencode 1.19.5) opens the shared opencode.db after OpenCode v2 (Desktop 2.2.5) has renamed session to session_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/cli

    If a v2 (2.x) CLI shows the same error, please comment here with opencode --version and we can take another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions