jackwener/OpenCLI · error · CommandExecutionError

settings.json not found: ${AG_SETTINGS_JSON}

Error message

settings.json not found: ${AG_SETTINGS_JSON}

What it means

Thrown by `antigravity settings-read` as a CommandExecutionError when the user settings file (~/Library/Application Support/Antigravity/User/settings.json) does not exist. The command reads and parses this JSONC file into key/value rows, so it requires the file to be present. Missing settings.json means the user has no custom user-level settings.

Source

Thrown at clis/antigravity/storage.js:346

            Modified: new Date(r.mtime).toISOString().replace('T', ' ').slice(0, 19),
        }));
    },
});

// ====== Settings ======
cli({
    site: 'antigravity',
    name: 'settings-read',
    access: 'read',
    description: 'Read Antigravity\'s user settings.json (theme, proxy, agCockpit, tfa.system.autoAccept, etc.).',
    domain: 'localhost',
    strategy: Strategy.LOCAL,
    browser: false,
    args: [],
    columns: STORAGE_COLUMNS,
    func: async () => {
        if (!fs.existsSync(AG_SETTINGS_JSON)) {
            throw new CommandExecutionError(`settings.json not found: ${AG_SETTINGS_JSON}`, '');
        }
        const raw = fs.readFileSync(AG_SETTINGS_JSON, 'utf-8');
        // VSCode allows JSONC (line + block comments + trailing commas).
        // Strip comments and trailing commas before parsing.
        const stripped = raw
            .replace(/\/\*[\s\S]*?\*\//g, '')              // block comments
            .replace(/^\s*\/\/.*$/gm, '')                  // line comments (full line)
            .replace(/([^:"])\/\/.*$/gm, '$1')             // line comments (after code)
            .replace(/,(\s*[}\]])/g, '$1');                // trailing commas
        let obj;
        try { obj = JSON.parse(stripped); } catch (e) {
            throw new CommandExecutionError(`Failed to parse settings.json: ${e.message}`, '');
        }
        const rows = [];
        for (const [k, v] of Object.entries(obj)) {
            rows.push({ Field: k, Value: typeof v === 'object' ? JSON.stringify(v) : String(v) });
        }
        return rows;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open Antigravity's Settings UI and change any setting so settings.json is created, then rerun
  2. Create the file manually: mkdir -p ~/Library/Application\ Support/Antigravity/User && echo '{}' > ~/Library/Application\ Support/Antigravity/User/settings.json
  3. Verify you are running the CLI as the same OS user that owns the Antigravity profile

Example fix

// before (file missing)
$ opencli antigravity settings-read
// CommandExecutionError: settings.json not found: ...

// after
$ mkdir -p "$HOME/Library/Application Support/Antigravity/User"
$ echo '{}' > "$HOME/Library/Application Support/Antigravity/User/settings.json"
$ opencli antigravity settings-read
Defensive patterns

Strategy: validation

Validate before calling

import * as fs from 'node:fs';
import * as path from 'node:path';
import * as os from 'node:os';
const settings = path.join(os.homedir(), 'Library/Application Support/Antigravity/User/settings.json');
if (!fs.existsSync(settings)) {
  fs.mkdirSync(path.dirname(settings), { recursive: true });
  fs.writeFileSync(settings, '{}\n');
}

Try / catch

try {
  await cli.run(['antigravity', 'settings-read']);
} catch (e) {
  if (String(e.message).startsWith('settings.json not found')) {
    console.log('No user settings yet — using defaults.');
  } else throw e;
}

Prevention

When it happens

Trigger: Running `opencli antigravity settings-read` when fs.existsSync(AG_SETTINGS_JSON) is false.

Common situations: Fresh Antigravity install where the user never modified settings via UI (VSCode-family apps create settings.json on first write); profile directory deleted; running as a different user whose home lacks the Antigravity dir.

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