{"record":{"id":"2c09a38cd0075cc1","repo":"jackwener/OpenCLI","slug":"state-vscdb-not-found-db","errorCode":null,"errorMessage":"state.vscdb not found: ${db}","messagePattern":"state\\.vscdb not found: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/antigravity/storage.js","lineNumber":44,"sourceCode":"    'Kind',\n    'Path',\n    'Workspace Id',\n    'Folder',\n    'Modified',\n    'Field',\n    'Value',\n];\n\n// ====== Path helpers ======\nconst AG_APP_SUPPORT = path.join(os.homedir(), 'Library/Application Support/Antigravity');\nconst AG_USER_DIR = path.join(AG_APP_SUPPORT, 'User');\nconst AG_GLOBAL_STATE_DB = path.join(AG_USER_DIR, 'globalStorage/state.vscdb');\nconst AG_WORKSPACE_STORAGE = path.join(AG_USER_DIR, 'workspaceStorage');\nconst AG_SETTINGS_JSON = path.join(AG_USER_DIR, 'settings.json');\n\nfunction sqliteQuery(db, sql) {\n    if (!fs.existsSync(db)) {\n        throw new CommandExecutionError(`state.vscdb not found: ${db}`, 'Has Antigravity been run at least once?');\n    }\n    try {\n        return execFileSync('/usr/bin/sqlite3', [db, sql], { encoding: 'utf-8', maxBuffer: 64 * 1024 * 1024 });\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 Antigravity instance. Try closing it or wait a few seconds.',\n        );\n    }\n}\nfunction 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}\nfunction getValue(db, key) {\n    const esc = key.replace(/'/g, \"''\");\n    const raw = sqliteQuery(db, `SELECT value FROM ItemTable WHERE key = '${esc}';`).trim();\n    if (!raw) return null;","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/antigravity/storage.js#L26-L62","documentation":"sqliteQuery in storage.js checks fs.existsSync on the target SQLite DB (typically ~/.antigravity/globalStorage/state.vscdb) before shelling out to /usr/bin/sqlite3; if the file is absent it throws a CommandExecutionError with a hint asking whether Antigravity has ever been run. The CLI reads Antigravity's internal state from this DB.","triggerScenarios":"Any storage subcommand (out/raw) calling sqliteQuery with a db path that doesn't exist on disk.","commonSituations":"Antigravity never launched on this machine so no profile/globalStorage exists; AG_USER_DIR env var points to the wrong/custom directory; different user/home when running under a service or sudo; typo'd explicit --db path; platform migration where the profile lives elsewhere.","solutions":["Launch Antigravity once so it creates its profile and state.vscdb","Verify the resolved path exists: ls ~/.antigravity/globalStorage/state.vscdb","Check/correct the AG_USER_DIR env var or path option pointing to the profile","Run the CLI as the same user that runs Antigravity (avoid sudo/home mismatch)","Pass an explicit db path if your profile is in a non-default location"],"exampleFix":"// before\nAG_USER_DIR=/wrong/path node serve.js\n// after\nexport AG_USER_DIR=$HOME/.antigravity  # or wherever the profile lives\nnode serve.js","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst db = process.env.AG_USER_DIR + '/globalStorage/state.vscdb';\nif (!fs.existsSync(db)) {\n  throw new Error(`state.vscdb missing at ${db}; launch Antigravity once first`);\n}","typeGuard":"function dbExists(dbPath) {\n  return typeof dbPath === 'string' && fs.existsSync(dbPath) && fs.statSync(dbPath).isFile();\n}","tryCatchPattern":"try {\n  const rows = storageOut();\n} catch (err) {\n  if (err.message.startsWith('state.vscdb not found')) {\n    console.error('Launch Antigravity once, or set AG_USER_DIR to its profile dir');\n  }\n  throw err;\n}","preventionTips":["Run Antigravity at least once before using storage commands","Run the CLI as the same user/home as Antigravity","Verify AG_USER_DIR points to the real profile directory","Use explicit db paths for non-default installs"],"tags":["filesystem","sqlite","configuration","antigravity"],"backgroundTag":"file-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}