{"record":{"id":"bf67b35ce5ca65fe","repo":"jackwener/OpenCLI","slug":"settings-json-not-found-trae-settings-json","errorCode":null,"errorMessage":"settings.json not found: ${TRAE_SETTINGS_JSON}","messagePattern":"settings\\.json not found: (.+?)","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/trae-solo/settings.js","lineNumber":32,"sourceCode":"    EmptyResultError,\n} from '@jackwener/opencli/errors';\nimport { TRAE_APP_SUPPORT } from './_fs.js';\n\nconst TRAE_SETTINGS_JSON = path.join(TRAE_APP_SUPPORT, 'User/settings.json');\n\ncli({\n    site: 'trae-solo',\n    name: 'settings-read',\n    access: 'read',\n    description: 'Parse and pretty-print Trae SOLO user settings.json (~/Library/Application Support/TRAE SOLO/User/settings.json). Handles VSCode JSONC syntax (line comments + trailing commas).',\n    domain: 'localhost',\n    strategy: Strategy.LOCAL,\n    browser: false,\n    args: [],\n    columns: ['Field', 'Value'],\n    func: async () => {\n        if (!fs.existsSync(TRAE_SETTINGS_JSON)) {\n            throw new EmptyResultError('trae-solo settings-read', `settings.json not found: ${TRAE_SETTINGS_JSON}`);\n        }\n        const raw = fs.readFileSync(TRAE_SETTINGS_JSON, 'utf-8');\n        // Strip JSONC: line comments + block comments + trailing commas.\n        const stripped = raw\n            .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n            .replace(/^\\s*\\/\\/.*$/gm, '')\n            .replace(/([^:\"])\\/\\/.*$/gm, '$1')\n            .replace(/,(\\s*[}\\]])/g, '$1');\n        let obj;\n        try { obj = JSON.parse(stripped); } catch (e) {\n            throw new CommandExecutionError(`Failed to parse settings.json: ${e.message}`, '');\n        }\n        const rows = [];\n        for (const [k, v] of Object.entries(obj)) {\n            rows.push({ Field: k, Value: typeof v === 'object' ? JSON.stringify(v) : String(v) });\n        }\n        if (!rows.length) {\n            throw new EmptyResultError('trae-solo settings-read', 'settings.json is empty (or contains only defaults).');","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-solo/settings.js#L14-L50","documentation":"EmptyResultError from the trae-solo `settings-read` command when Trae's settings.json does not exist at the TRAE_SETTINGS_JSON path. The command reads the file from disk (LOCAL strategy, no browser), strips JSONC comments/trailing commas, then parses; without the file there is nothing to read, so it fails with the full path for debugging.","triggerScenarios":"TRAE_SETTINGS_JSON points to a location where Trae never wrote settings (fresh install, settings not yet customized); TRAE config directory moved or the env var/constant targets the wrong platform path (e.g. Linux vs macOS vs Windows); settings were deleted or a portable/custom install uses a different data dir.","commonSituations":"Running the tool on a machine where Trae was never launched; pointing at ~/.trae vs the actual app-data path (~/Library/Application Support/Trae, %APPDATA%\\Trae, ~/.config/Trae); sandboxed/CI environments without the user's Trae profile.","solutions":["Open Trae once and change any setting so settings.json is created, then re-run.","Verify TRAE_SETTINGS_JSON points to the correct per-OS path where Trae actually stores settings.","Check that the user running the tool can see the file (permissions, correct HOME in CI/containers).","Create/copy a valid settings.json at the expected path if you intend to seed config."],"exampleFix":"// before\nconst v = await cli('trae-solo', 'settings-read'); // not found\n// after\nimport fs from 'fs';\nif (!fs.existsSync(TRAE_SETTINGS_JSON)) {\n  console.error('Launch Trae once to generate:', TRAE_SETTINGS_JSON);\n} else {\n  const v = await cli('trae-solo', 'settings-read');\n}","handlingStrategy":"try-catch","validationCode":"import fs from 'fs';\nif (!fs.existsSync(TRAE_SETTINGS_JSON)) {\n  throw new Error(`Trae settings.json missing at ${TRAE_SETTINGS_JSON} — launch Trae once first`);\n}","typeGuard":"const settingsReadable = (p) => { try { return fs.statSync(p).isFile(); } catch { return false; } };","tryCatchPattern":"try {\n  settings = await cli('trae-solo', 'settings-read');\n} catch (e) {\n  if (/settings.json not found/.test(e.message)) {\n    console.warn(`No settings at ${e.message.split(': ')[1]} — using defaults`);\n    settings = DEFAULT_SETTINGS;\n  } else throw e;\n}","preventionTips":["Launch Trae at least once on the machine before reading settings.","Resolve the settings path per-OS (Linux ~/.config, macOS Application Support, Windows %APPDATA%).","Check file existence/permissions in CI before invoking.","Handle first-run environments with sane defaults instead of failing."],"tags":["file-not-found","settings","trae","config"],"backgroundTag":"settings-file-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}