thedotmack/claude-mem · warning
[SETTINGS] Failed to load settings, using defaults:
Error message
[SETTINGS] Failed to load settings, using defaults:
What it means
SettingsDefaultsManager wraps reading, parsing, and flattening of ~/.claude-mem/settings.json in one try/catch. Any failure (unreadable file, malformed JSON, wrong value shape) logs this warning and silently returns the compiled-in DEFAULTS, optionally with CLAUDE_MEM_* env overrides applied. It never throws; callers cannot distinguish 'defaults' from 'user settings'.
Source
Thrown at src/shared/SettingsDefaultsManager.ts:289
writeJsonFileAtomic(settingsPath, flatSettings);
// stderr, never stdout — same JSON-on-stdout contract as above.
console.warn('[SETTINGS] Migrated Telegram trigger types off the legacy default:', settingsPath);
} catch (error: unknown) {
console.warn('[SETTINGS] Failed to migrate Telegram trigger types:', settingsPath, error instanceof Error ? error.message : String(error));
// Continue with the in-memory migration even if the write fails
}
}
const result: SettingsDefaults = { ...this.DEFAULTS };
for (const key of Object.keys(this.DEFAULTS) as Array<keyof SettingsDefaults>) {
if (flatSettings[key] !== undefined) {
result[key] = flatSettings[key];
}
}
return applyEnvOverrides ? this.applyEnvOverrides(result) : result;
} catch (error: unknown) {
console.warn('[SETTINGS] Failed to load settings, using defaults:', settingsPath, error instanceof Error ? error.message : String(error));
const defaults = this.getAllDefaults();
return applyEnvOverrides ? this.applyEnvOverrides(defaults) : defaults;
}
}
}
View on GitHub (pinned to e2d1df569a)
Solutions
- Validate the file: run `cat ~/.claude-mem/settings.json | jq .` and fix the syntax error jq reports (jq tolerates no trailing commas, same as the parser).
- Re-run `npx claude-mem install` or the doctor command so claude-mem regenerates a valid settings file.
- Rename the broken file (mv ~/.claude-mem/settings.json settings.json.bak) so the next load cleanly regenerates defaults instead of warning on every startup.
- Set needed values via CLAUDE_MEM_* environment variables instead — env overrides are applied even on the defaults fallback path.
Example fix
// ~/.claude-mem/settings.json — before (trailing comma is invalid JSON):
{
"CLAUDE_MEM_PROVIDER": "claude",
"CLAUDE_MEM_WORKER_PORT": 3777,
}
// after:
{
"CLAUDE_MEM_PROVIDER": "claude",
"CLAUDE_MEM_WORKER_PORT": 3777
} Defensive patterns
Strategy: validation
Validate before calling
// Before relying on user settings, confirm the file parses and is readable:
import { readFileSync } from 'node:fs';
const path = `${process.env.HOME}/.claude-mem/settings.json`;
try {
JSON.parse(readFileSync(path, 'utf-8').replace(/^\uFEFF/, ''));
// file is valid — the loader will honor it
} catch {
// file broken — the loader WILL silently fall back to defaults; fix or delete first
} Type guard
const isPlainObject = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);
Try / catch
// The loader never throws, so catch is unnecessary — instead detect the fallback: // run your own JSON.parse on the settings path first; if it throws, the value // returned by SettingsDefaultsManager is defaults, not user intent.
Prevention
- Never hand-edit settings.json without validating with `jq .` afterwards.
- Keep a backup before installer runs: cp settings.json settings.json.bak.
- Set machine-specific values via CLAUDE_MEM_* env vars — they apply even on the defaults fallback.
- Treat any '[SETTINGS] Failed to load settings' line in logs as 'user settings were IGNORED', not noise.
When it happens
Trigger: Calling the settings loader when settings.json contains invalid JSON (trailing comma, comment, unquoted key), when the file has mode 000 or is owned by another user, or when a value fails the internal flattening/type check inside the try block. All downstream logic in the same try lands on this same warn line.
Common situations: Hand-editing settings.json and leaving a trailing comma; another process writing the file non-atomically while it is read; a partial write left by a killed install; copying settings between machines with different permissions; a stray BOM when the file was created by PowerShell without the BOM-aware parser path.
Related errors
- generation parse error: ${outcome.reason}
- generation job ${job.id} not found in scope
- Failed to read existing settings file; starting fresh
- [install] Failed to parse existing settings.json, starting f
- bun install failed in ${targetDir} ${describeExecError(err)}
AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20).
Data as JSON: /api/errors/4318ae8740f5a541.
Report an issue: GitHub.