jackwener/OpenCLI · warning · EmptyResultError
settings.json not found: ${TRAE_SETTINGS_JSON}
Error message
settings.json not found: ${TRAE_SETTINGS_JSON} What it means
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.
Source
Thrown at clis/trae-solo/settings.js:32
EmptyResultError,
} from '@jackwener/opencli/errors';
import { TRAE_APP_SUPPORT } from './_fs.js';
const TRAE_SETTINGS_JSON = path.join(TRAE_APP_SUPPORT, 'User/settings.json');
cli({
site: 'trae-solo',
name: 'settings-read',
access: 'read',
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).',
domain: 'localhost',
strategy: Strategy.LOCAL,
browser: false,
args: [],
columns: ['Field', 'Value'],
func: async () => {
if (!fs.existsSync(TRAE_SETTINGS_JSON)) {
throw new EmptyResultError('trae-solo settings-read', `settings.json not found: ${TRAE_SETTINGS_JSON}`);
}
const raw = fs.readFileSync(TRAE_SETTINGS_JSON, 'utf-8');
// Strip JSONC: line comments + block comments + trailing commas.
const stripped = raw
.replace(/\/\*[\s\S]*?\*\//g, '')
.replace(/^\s*\/\/.*$/gm, '')
.replace(/([^:"])\/\/.*$/gm, '$1')
.replace(/,(\s*[}\]])/g, '$1');
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) });
}
if (!rows.length) {
throw new EmptyResultError('trae-solo settings-read', 'settings.json is empty (or contains only defaults).');View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before
const v = await cli('trae-solo', 'settings-read'); // not found
// after
import fs from 'fs';
if (!fs.existsSync(TRAE_SETTINGS_JSON)) {
console.error('Launch Trae once to generate:', TRAE_SETTINGS_JSON);
} else {
const v = await cli('trae-solo', 'settings-read');
} Defensive patterns
Strategy: try-catch
Validate before calling
import fs from 'fs';
if (!fs.existsSync(TRAE_SETTINGS_JSON)) {
throw new Error(`Trae settings.json missing at ${TRAE_SETTINGS_JSON} — launch Trae once first`);
} Type guard
const settingsReadable = (p) => { try { return fs.statSync(p).isFile(); } catch { return false; } }; Try / catch
try {
settings = await cli('trae-solo', 'settings-read');
} catch (e) {
if (/settings.json not found/.test(e.message)) {
console.warn(`No settings at ${e.message.split(': ')[1]} — using defaults`);
settings = DEFAULT_SETTINGS;
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- File not found: ${path}
- settings.json not found: ${AG_SETTINGS_JSON}
- ${preparedImages.reason}
- Cover image file not found: ${imagePath}
- 视频文件不存在: ${videoPath}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bf67b35ce5ca65fe.
Report an issue: GitHub.