Repository navigation
Description
Description
After upgrading to 2.3.0 on a Raspberry Pi (Debian 13 / arm64), OpenCode Desktop exits immediately after app starting, and the bundled CLI background service (opencode serve --service) cannot boot. Both failures are caused by the same conflict: two 2.3.0 migrations create a blob table unconditionally, but the database (created by the V1→V2 migration in August) already contains a legacy blob table.
1. CLI migration 20261025123711_blob
database migration started migration=20261025123711_blob
database migration failed migration=20261025123711_blob durationMs=2
error="... CREATE TABLE `blob` ( `hash` text PRIMARY KEY, `mime` text NOT NULL, ... )
(cause: SQLiteError: table `blob` already exists)"
background service boot failed
GET /api/info 500
The legacy table is blob(id TEXT PRIMARY KEY, data BLOB NOT NULL) with 0 rows, and it is part of the V1→V2 baseline schema (it is not recorded in the migration table, whose 51 rows only go up to 20261010180456_project_time_archived). The new migration assumes the table does not exist and does a bare CREATE TABLE.
2. Desktop drafts migrations applied to the shared CLI database
The desktop app applies its own drafts migrations to ~/.config/ai.opencode.desktop/drafts.sqlite. On this machine that path is a symlink to the shared CLI database (~/.local/share/opencode/opencode.db), created by the V1→V2 data migration on 2026-08-22:
~/.config/ai.opencode.desktop/drafts.sqlite -> ~/.local/share/opencode/opencode.db
~/.local/state/opencode/opencode.db -> ~/.local/share/opencode/opencode.db
Migration 20260906234153_drafts does CREATE TABLE \blob` (id, data)andCREATE TABLE `document` (key, value)`, and both tables already exist in the CLI database. The whole transaction fails and the app quits before showing a window:
[03:44:10] (main) app starting { version: '2.3.0', ... }
[03:45:54.351] ERROR (#3): Error: table `blob` already exists
at file:///opt/OpenCode/resources/app.asar/out/main/index.js:1:5784
at Array.forEach (<anonymous>)
at De (file:///opt/OpenCode/resources/app.asar/out/main/index.js:1:5732)
Every subsequent launch fails identically, and because the failed serve --service process stays alive and keeps answering /api/info with 500, the desktop only shows "Background service failed to start" until the service process is killed and the stale service.json removed.
OpenCode version
2.3.0 — Desktop ai.opencode.desktop 2.3.0 (/opt/OpenCode, bundled opencode-cli 2.3.0) and CLI opencode 2.3.0. Before the upgrade the CLI on this machine was 2.1.4, which worked with the same database.
Plugins
None configured. ~/.config/opencode/opencode.jsonc only defines a model and a local @ai-sdk/openai-compatible provider.
Steps to reproduce
- Start from a database created by the V1→V2 migration (in this case 2026-08-22) where the baseline schema already contains the legacy tables
blob(id TEXT PRIMARY KEY, data BLOB NOT NULL)anddocument(key TEXT PRIMARY KEY, value TEXT NOT NULL), and where themigrationtable has no20260906234153_draftsrow. - Keep the V1→V2 symlink
~/.config/ai.opencode.desktop/drafts.sqlite -> ~/.local/share/opencode/opencode.db. - Upgrade CLI and/or Desktop to 2.3.0 and launch Desktop.
- Desktop writes
app startingand quits withError: table \blob` already exists`. - If the drafts symlink is removed (
opencode service restartafterwards), the service then fails on migration20261025123711_blobwith the same error and/api/inforeturns 500.
Operating System
Debian GNU/Linux 13 (trixie), Linux 6.18.50+rpt-rpi-v8 aarch64 (Raspberry Pi 5), Raspberry Pi OS labwc/Wayland session, accessed over wayvnc.
Terminal
Not applicable (Desktop app). Diagnostics were run over SSH with bash.
Additional Context
Schema state before the fix
blob=CREATE TABLE blob (id TEXT PRIMARY KEY, data BLOB NOT NULL)— 0 rowsdocument=CREATE TABLE document (key TEXT PRIMARY KEY, value TEXT NOT NULL)— 3 rowsstate,plugin,extension,blob_refmissingmigrationtable: 51 rows, latest20261010180456_project_time_archivedkvcontainsmigration.v1-v2 = {"phase":"completed"}
Workaround that restored the app
- Backed up the database (
sqlite3/backup()copy). - Replaced the
drafts.sqlitesymlink with a real, empty file so the desktop drafts migrations get their own database. - Renamed the legacy, empty table:
ALTER TABLE \blob` RENAME TO `blob_v1_legacy``. - Killed the stuck
opencode-cli serve --serviceprocess and removed~/.local/state/opencode/service.json.
After that, migrations completed through 20261030054400_job, blob_ref and the new blob(hash, mime, bytes, width, height, data, time_created) were created, /api/info returned 200, and the desktop window opened with all projects and sessions intact.
Suggested fixes
- Make the desktop drafts store independent of the shared CLI database (do not follow the V1→V2 symlink), or make its migrations
IF NOT EXISTS/schema-aware. - Make
20261025123711_blobtolerate a pre-existing legacyblobtable (rename/recreate, or record the V1→V2 baseline inmigrationso baseline tables are not recreated). - Do not leave a failed
serve --serviceprocess serving500on/api/info, which turns a migration error into a permanently broken Desktop until the process andservice.jsonare removed manually.
Activity
opencodejr commentedon Nov 14, 2026
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I reproduced the CLI half on 2.3.0, and it still happens on the latest
dev(cbe7159).What I did (the script below):
opencode serve). Its last migration was20261010180456_project_time_archived, as on your machine.blob(id TEXT PRIMARY KEY, data BLOB NOT NULL)anddocument(key, value)tables you describe. This setup step is simulated: I don't have a real V1→V2 database.opencode servefrom 2.3.0 on that data. Migration20261025123711_blobfailed withSQLiteError: table \blob` already existsand the server did not start. Running fromdev` source gives the same failure.Not checked:
serveexited instead.drafts.sqlitesymlink comes from: I didn't find code that creates it.The old
blob/documenttables match the desktop drafts schema exactly, which fits your symlink explanation. I've passed the details to the maintainers.Reproduction script (repro.sh)
Run it:
bash repro.shccclucky commentedon Nov 14, 2026
Taking this one.
Confirmed on
dev(cbe7159): migration20261025123711_blobdoes a bareCREATE TABLE blob (...)(packages/core/src/database/migration/20261025123711_blob.ts), but databases that went through the V1→V2 data migration in August already carry the baselineblob(id, data)table, so the migration dies withtable blob already existsand the background service never boots.A real
blob(hash, ...)table cannot exist on those databases (the migration would have created it itself, and it never completed there), so the migration can detect the legacy shape and set it aside:PRAGMA table_info(blob): if the table exists and has nohashcolumn — the legacy baseline shape — rename it toblob_v1_legacyinstead of failing. Any rows survive, and the rename is transactional with the rest of the migration (each migration already runs in one transaction). Same guard pattern as the existingsession-metadatamigration.packages/core/test/database-migration.test.ts: a database holding the legacyblobtable (with a row) applies the migration successfully, ends up with the newblob(hash, ...)schema, and keeps the renamed legacy table intact.I'll leave the desktop drafts half to maintainers — decoupling
drafts.sqlitefrom the shared CLI database (or making the drafts store schema-aware) is a product decision I don't want to make unilaterally. The stuckserve --serviceprocess answering 500 after a failed boot also looks like a separate error-handling issue, so I'm not folding it in here.