jackwener/OpenCLI · error · CommandExecutionError

sqlite3 failed on ${path.basename(db)}: ${e.message}

Error message

sqlite3 failed on ${path.basename(db)}: ${e.message}

What it means

sqliteQuery runs execFileSync('/usr/bin/sqlite3', ...) and wraps any failure (non-zero exit, spawn error, or EBUSY) into this CommandExecutionError. The most common underlying cause per the remedy is the database being locked by a live Trae SOLO instance holding a write lock on the same SQLite file.

Source

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

    '.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.
export function listKeys(db) {
    const out = sqliteQuery(db, 'SELECT key FROM ItemTable ORDER BY key;');
    return out.split('\n').map((s) => s.trim()).filter(Boolean);
}

// Get a single value by key. Returns null if absent. Auto-parses JSON when
// possible.
export function getValue(db, key) {
    // Escape single quotes for sqlite literal.
    const esc = key.replace(/'/g, "''");
    const raw = sqliteQuery(

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Close the Trae SOLO app (or wait a few seconds) so the DB lock is released, then retry
  2. Verify the SQL string is valid by running it manually: sqlite3 <db> "<sql>"
  3. Check /usr/bin/sqlite3 exists (which sqlite3); install sqlite3 or adjust the binary path
  4. Inspect e.message in the error for the actual sqlite exit reason (locked vs syntax vs corrupt); if corrupt, restore from backup

Example fix

// before
const rows = traeSoloCli.state.raw(db, "SELECT value FROM ItemTable");
// after (close Trae first / retry)
function rawRetry(db, sql, tries = 5) {
  try { return traeSoloCli.state.raw(db, sql); }
  catch (e) {
    if (/locked/i.test(e.message) && tries > 0) {
      Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2000);
      return rawRetry(db, sql, tries - 1);
    }
    throw e;
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

import fs from 'fs';
if (!fs.existsSync('/usr/bin/sqlite3')) throw new Error('sqlite3 not installed at /usr/bin/sqlite3');

Try / catch

try {
  return traeSoloCli.state.raw(db, sql);
} catch (e) {
  if (/locked/i.test(e.message)) { /* close Trae, wait, retry */ }
  else if (/unable to open|syntax/i.test(e.message)) { /* fix SQL or path */ }
  throw e;
}

Prevention

When it happens

Trigger: The sqlite3 binary fails on the given db: DB locked by running Trae SOLO, corrupt DB, malformed SQL passed to raw(), or sqlite3 not usable at /usr/bin/sqlite3.

Common situations: Querying state.vscdb while Trae SOLO is open and holding a lock; passing invalid SQL to raw(); DB corruption after a crash; minimal containers missing /usr/bin/sqlite3 (wrong path) causing spawn failure.

Related errors


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