{"record":{"id":"cffb07b95e13db69","repo":"jackwener/OpenCLI","slug":"sqlite3-failed-on-path-basename-db-e-messag-cffb07","errorCode":null,"errorMessage":"sqlite3 failed on ${path.basename(db)}: ${e.message}","messagePattern":"sqlite3 failed on (.+?): (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-solo/_state.js","lineNumber":49,"sourceCode":"    '.trae/extensions/extensions.json',\n);\n\n// Run `sqlite3 <db> \"<sql>\"` and return stdout as a string. Throws\n// CommandExecutionError on sqlite failure.\nexport function sqliteQuery(db, sql) {\n    if (!fs.existsSync(db)) {\n        throw new CommandExecutionError(\n            `state.vscdb not found: ${db}`,\n            'Has Trae SOLO been run at least once?',\n        );\n    }\n    try {\n        return execFileSync('/usr/bin/sqlite3', [db, sql], {\n            encoding: 'utf-8',\n            maxBuffer: 64 * 1024 * 1024,\n        });\n    } catch (e) {\n        throw new CommandExecutionError(\n            `sqlite3 failed on ${path.basename(db)}: ${e.message}`,\n            'The DB may be locked by a running Trae SOLO instance. Try closing it or wait a few seconds.',\n        );\n    }\n}\n\n// List all keys in an ItemTable.\nexport function listKeys(db) {\n    const out = sqliteQuery(db, 'SELECT key FROM ItemTable ORDER BY key;');\n    return out.split('\\n').map((s) => s.trim()).filter(Boolean);\n}\n\n// Get a single value by key. Returns null if absent. Auto-parses JSON when\n// possible.\nexport function getValue(db, key) {\n    // Escape single quotes for sqlite literal.\n    const esc = key.replace(/'/g, \"''\");\n    const raw = sqliteQuery(","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-solo/_state.js#L31-L67","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Close the Trae SOLO app (or wait a few seconds) so the DB lock is released, then retry","Verify the SQL string is valid by running it manually: sqlite3 <db> \"<sql>\"","Check /usr/bin/sqlite3 exists (which sqlite3); install sqlite3 or adjust the binary path","Inspect e.message in the error for the actual sqlite exit reason (locked vs syntax vs corrupt); if corrupt, restore from backup"],"exampleFix":"// before\nconst rows = traeSoloCli.state.raw(db, \"SELECT value FROM ItemTable\");\n// after (close Trae first / retry)\nfunction rawRetry(db, sql, tries = 5) {\n  try { return traeSoloCli.state.raw(db, sql); }\n  catch (e) {\n    if (/locked/i.test(e.message) && tries > 0) {\n      Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2000);\n      return rawRetry(db, sql, tries - 1);\n    }\n    throw e;\n  }\n}","handlingStrategy":"try-catch","validationCode":"import fs from 'fs';\nif (!fs.existsSync('/usr/bin/sqlite3')) throw new Error('sqlite3 not installed at /usr/bin/sqlite3');","typeGuard":null,"tryCatchPattern":"try {\n  return traeSoloCli.state.raw(db, sql);\n} catch (e) {\n  if (/locked/i.test(e.message)) { /* close Trae, wait, retry */ }\n  else if (/unable to open|syntax/i.test(e.message)) { /* fix SQL or path */ }\n  throw e;\n}","preventionTips":["Close Trae SOLO before querying its SQLite state directly","Validate SQL strings against a copy of the DB before running raw()","Install sqlite3 at the expected path in minimal containers","Keep backups of state.vscdb before ad-hoc queries"],"tags":["sqlite","locked-database","subprocess","trae-solo"],"backgroundTag":"database-locked","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}