Skip to content

npm: opencode-ai (v1, latest=1.19.5) is not deprecated and silently breaks after Desktop v2 migrates the shared database #63044

Closed as not planned

Description

@luckystation-cmd

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 npm latest tag) and opencode 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.md and opencode.jsonc exist, no plugins entry)

Reproduction

  1. npm install -g opencode-ai — installs what npm still advertises as latest (1.19.5), with no deprecation warning.
  2. Install and use OpenCode Desktop 2.2.6. It creates/migrates the shared data directory ~/.local/share/opencode/opencode.db (table session becomes session_v2; the file contains 13 sessions at the time of writing).
  3. From a terminal, run any of:
    • opencode stats
    • opencode session list
    • opencode db path

Expected Behavior

One of:

  • opencode-ai is 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 set OPENCODE_DATA_DIR to 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

  1. opencodejr commented on Nov 10, 2026

    @opencodejr
    Contributor

    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 same opencode.db fine). So a v1-side change, like a clearer error when v1 finds a database that v2 has migrated, is unlikely to happen.

    Workarounds:

    • Use the v2 CLI, npm install -g @opencode/cli, which reads the data Desktop 2.x writes. Uninstall opencode-ai first (or make sure the v2 opencode comes first on your PATH) so the old 1.19.5 binary doesn't keep running.
    • If you really need v1 as well, give it its own database with OPENCODE_DB or a separate data directory, so it never opens the file v2 migrated.

    I've passed your suggestion to deprecate the opencode-ai npm 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:

    If you think this is critical, or you see the same problem with the v2 CLI, please reply here and say so.

  2. opencodejr commented on Nov 11, 2026

    @opencodejr
    Contributor

    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 your opencode.db fine.

    To get a working CLI, install the v2 package with npm install -g @opencode/cli. Uninstall opencode-ai first, or make sure the v2 opencode comes first on your PATH. If you need v1 as well, give it its own database with OPENCODE_DB or a separate data directory.

    Deprecating opencode-ai on 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.

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