jackwener/OpenCLI · error · CommandExecutionError

state.vscdb not found: ${db}

Error message

state.vscdb not found: ${db}

What it means

sqliteQuery shells out to /usr/bin/sqlite3 against a Trae SOLO state.vscdb database. It first checks the DB file exists and throws this CommandExecutionError if it does not, since the query cannot possibly succeed. Like the assertReadable family, it indicates Trae SOLO has never been initialized on this machine/user.

Source

Thrown at clis/trae-solo/_state.js:38

export const TRAE_USER_DIR_APP = path.join(TRAE_APP_SUPPORT, 'User');
export const TRAE_GLOBAL_STATE_DB = path.join(
    TRAE_USER_DIR_APP,
    'globalStorage/state.vscdb',
);
export const TRAE_WORKSPACE_STORAGE = path.join(
    TRAE_USER_DIR_APP,
    'workspaceStorage',
);
export const TRAE_EXTENSIONS_JSON = path.join(
    process.env.HOME || '',
    '.trae/extensions/extensions.json',
);

// Run `sqlite3 <db> "<sql>"` and return stdout as a string. Throws
// CommandExecutionError on sqlite failure.
export function sqliteQuery(db, sql) {
    if (!fs.existsSync(db)) {
        throw new CommandExecutionError(
            `state.vscdb not found: ${db}`,
            'Has Trae SOLO been run at least once?',
        );
    }
    try {
        return execFileSync('/usr/bin/sqlite3', [db, sql], {
            encoding: 'utf-8',
            maxBuffer: 64 * 1024 * 1024,
        });
    } catch (e) {
        throw new CommandExecutionError(
            `sqlite3 failed on ${path.basename(db)}: ${e.message}`,
            'The DB may be locked by a running Trae SOLO instance. Try closing it or wait a few seconds.',
        );
    }
}

// List all keys in an ItemTable.

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run Trae SOLO at least once to create state.vscdb
  2. Confirm the exact DB path printed in the error exists (ls it) and you're the same user as the Trae install
  3. If a custom path was passed to raw/out, fix the path
  4. If a Trae upgrade relocated the DB, update the path or reinstall/launch Trae

Example fix

// before
const v = traeSoloCli.state.raw(db, 'SELECT ...'); // throws
// after
import fs from 'fs';
if (!fs.existsSync(db)) throw new Error(`Run Trae SOLO once to create ${db}`);
const v = traeSoloCli.state.raw(db, 'SELECT ...');
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'fs';
if (!fs.existsSync(db)) throw new Error(`state.vscdb missing at ${db} — run Trae SOLO once.`);

Type guard

function dbExists(db) {
  return typeof db === 'string' && fs.existsSync(db) && fs.statSync(db).size > 0;
}

Try / catch

try {
  return traeSoloCli.state.raw(db, sql);
} catch (e) {
  if (/state.vscdb not found/.test(e.message)) {
    throw new Error('Initialize Trae SOLO first: ' + e.message);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling state-reading helpers (out() or raw(), which call sqliteQuery) with a db path for state.vscdb that does not exist on disk.

Common situations: Trae SOLO never launched; running under a different user/HOME than the one where Trae stores its state; typo'd or custom DB path argument; Trae data wiped by cleanup tooling or a version migration moved the DB.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/6dc994a45c1301a9. Report an issue: GitHub.