jackwener/OpenCLI · error · CommandExecutionError

state.vscdb not found: ${db}

Error message

state.vscdb not found: ${db}

What it means

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.

Source

Thrown at clis/antigravity/storage.js:44

    'Kind',
    'Path',
    'Workspace Id',
    'Folder',
    'Modified',
    'Field',
    'Value',
];

// ====== Path helpers ======
const AG_APP_SUPPORT = path.join(os.homedir(), 'Library/Application Support/Antigravity');
const AG_USER_DIR = path.join(AG_APP_SUPPORT, 'User');
const AG_GLOBAL_STATE_DB = path.join(AG_USER_DIR, 'globalStorage/state.vscdb');
const AG_WORKSPACE_STORAGE = path.join(AG_USER_DIR, 'workspaceStorage');
const AG_SETTINGS_JSON = path.join(AG_USER_DIR, 'settings.json');

function sqliteQuery(db, sql) {
    if (!fs.existsSync(db)) {
        throw new CommandExecutionError(`state.vscdb not found: ${db}`, 'Has Antigravity 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 Antigravity instance. Try closing it or wait a few seconds.',
        );
    }
}
function listKeys(db) {
    const out = sqliteQuery(db, 'SELECT key FROM ItemTable ORDER BY key;');
    return out.split('\n').map((s) => s.trim()).filter(Boolean);
}
function getValue(db, key) {
    const esc = key.replace(/'/g, "''");
    const raw = sqliteQuery(db, `SELECT value FROM ItemTable WHERE key = '${esc}';`).trim();
    if (!raw) return null;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Launch Antigravity once so it creates its profile and state.vscdb
  2. Verify the resolved path exists: ls ~/.antigravity/globalStorage/state.vscdb
  3. Check/correct the AG_USER_DIR env var or path option pointing to the profile
  4. Run the CLI as the same user that runs Antigravity (avoid sudo/home mismatch)
  5. Pass an explicit db path if your profile is in a non-default location

Example fix

// before
AG_USER_DIR=/wrong/path node serve.js
// after
export AG_USER_DIR=$HOME/.antigravity  # or wherever the profile lives
node serve.js
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
const db = process.env.AG_USER_DIR + '/globalStorage/state.vscdb';
if (!fs.existsSync(db)) {
  throw new Error(`state.vscdb missing at ${db}; launch Antigravity once first`);
}

Type guard

function dbExists(dbPath) {
  return typeof dbPath === 'string' && fs.existsSync(dbPath) && fs.statSync(dbPath).isFile();
}

Try / catch

try {
  const rows = storageOut();
} catch (err) {
  if (err.message.startsWith('state.vscdb not found')) {
    console.error('Launch Antigravity once, or set AG_USER_DIR to its profile dir');
  }
  throw err;
}

Prevention

When it happens

Trigger: Any storage subcommand (out/raw) calling sqliteQuery with a db path that doesn't exist on disk.

Common situations: 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.

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/2c09a38cd0075cc1. Report an issue: GitHub.