Skip to content

opencode crashes on start with SQLITE_CORRUPT #30157

Closed

Description

@flexdinesh

Description

I can't use opencode anymore. Startup crashes. Logs:

INFO  2026-06-01T02:02:56 +115ms service=default version=1.15.13 args=["debug","info"] process_role=main run_id=02f6fe66-d0c0-4120-aff3-f795c72b4717 opencode
INFO  2026-06-01T02:02:56 +4ms service=file init
INFO  2026-06-01T02:02:56 +250ms service=db path=/Users/myuser/.local/share/opencode/opencode.db opening database
ERROR 2026-06-01T02:02:56 +3ms service=default cause={"_id":"Cause","failures":[{"_tag":"Die","defect":{"name":"DrizzleError","cause":{"code":"SQLITE_CORRUPT","errno":11,"byteOffset":-1}}}]} failed to run data migrations
INFO  2026-06-01T02:02:56 +14ms service=default directory=/Users/myuser/.config/opencode creating instance
INFO  2026-06-01T02:02:56 +0ms service=project directory=/Users/myuser/.config/opencode fromDirectory
INFO  2026-06-01T02:02:56 +2ms service=db path=/Users/myuser/.local/share/opencode/opencode.db opening database

terminal output

~/.config/opencode via  v24.14.1
❯ opencode
Error: 4 of 5 requests failed: Unexpected server error. Check server logs for details.
Affected startup requests: config.providers, provider.list, app.agents, config.get
    at sO (/$bunfs/root/chunk-7kbvbz65.js:468:117)
    at <anonymous> (/$bunfs/root/chunk-7kbvbz65.js:468:5550)
    at processTicksAndRejections (native:7:39)

~/.config/opencode via  v24.14.1
❯ opencode debug info
Error: Unexpected error, check log file at /Users/myuser/.local/share/opencode/log/2026-06-01T020256.log for more details

Failed to run the query 'PRAGMA journal_mode = WAL'

Plugins

none

OpenCode version

1.15.13

Steps to reproduce

  1. Start OpenCode
  2. Crashes

Screenshot and/or share link

Image

Operating System

macOS Tahoe 26.5

Terminal

Ghostty

Activity

  1. github-actions commented on Jun 1, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is specifically caused by a corrupted database file, you may be able to resolve it by removing or renaming ~/.local/share/opencode/opencode.db and restarting opencode (note: this will clear your session history).

  2. flexdinesh commented on Jun 1, 2026

    @flexdinesh
    Author

    FWIW, this happened around the time I was messing around with mounting my opencode config dir into a Docker container locally. So there's a good chance this is due to a SQLite file-locking failure.

  3. flexdinesh commented on Jun 1, 2026

    @flexdinesh
    Author

    I fixed this by deleting the opencode database and letting opencode recreate it
    rm ~/.local/share/opencode/opencode.db

    ~/.config/opencode via  v24.14.1
    ❯ rm ~/.local/share/opencode/opencode.db
    
    ~/.config/opencode via  v24.14.1
    ❯ opencode
    Performing one time database migration, may take a few minutes...
    ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% todos        2494/2494
    ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% complete     2494/2494
    Database migration complete.
    
    
  4. bapijun commented on Jul 14, 2026

    @bapijun

    rm ~/.local/share/opencode/opencode.db
    is great idea.
    I'm guessing it's because I failed to update OpenCode.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions