thedotmack/claude-mem · warning
[uninstall] Could not read settings for server runtime…
Error message
[uninstall] Could not read settings for server runtime cleanup:
What it means
During uninstall, clearServerRuntimeSettings reads flat settings to remove server-runtime-related keys. If readFlatSettings(USER_SETTINGS_PATH) throws, it logs this warning and returns early — server runtime settings keys are left untouched in the settings file.
Solutions
- Fix or restore ~/.claude/settings.json (valid JSON, readable by current user), then re-run uninstall.
- Manually remove the server runtime keys (e.g. CLAUDE_MEM_RUNTIME and related server keys) from settings.json with an editor.
- Ignore if the file intentionally doesn't exist — leftover keys are inert after uninstall.
Example fix
// before: unreadable settings ls -l ~/.claude/settings.json # -rw------- root root // after sudo chown $USER ~/.claude/settings.json npx claude-mem uninstall
Defensive patterns
Strategy: fallback
Validate before calling
// Ensure settings are readable before cleanup
import { accessSync, constants } from 'node:fs';
accessSync(USER_SETTINGS_PATH, constants.R_OK); Type guard
function isFlatSettings(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null && !Array.isArray(v);
} Try / catch
let flat: Record<string, unknown> | null;
try {
flat = readFlatSettings(USER_SETTINGS_PATH);
} catch (error) {
console.warn('[uninstall] Could not read settings for server runtime cleanup:', error instanceof Error ? error.message : String(error));
return; // skip key removal, continue uninstall
} Prevention
- Verify read permission on settings.json before uninstall
- Fix JSON syntax errors before running cleanup commands
- Don't delete the settings file mid-operation
- Manually strip server keys afterward if the warning appeared
When it happens
Trigger: Running `claude-mem uninstall` when reading the user settings file fails (file missing, permission denied, or invalid JSON inside readFlatSettings).
Common situations: Corrupted or hand-edited settings.json; restrictive permissions after running commands with sudo; settings file removed mid-uninstall; unreadable home directory on shared systems.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- claude-mem does not appear to be installed.
- [uninstall] Could not read
- [uninstall] Could not read selected runtime from settings…
- [uninstall] Could not rewrite
- [uninstall] Could not write settings during server runtime…
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/e6c28c26798bfb18.
Report an issue: GitHub.
Appendix: source
Thrown at src/npx-cli/commands/uninstall.ts:47
// the matching teardown. The worker path is the default and is unchanged: only
// when the recorded runtime is the server runtime do we run the extra teardown.
function readSelectedRuntime(): InstallRuntimeId {
try {
const settings = SettingsDefaultsManager.loadFromFile(USER_SETTINGS_PATH);
return normalizeRuntimeFlag(settings.CLAUDE_MEM_RUNTIME) ?? 'worker';
} catch (error: unknown) {
const err = error instanceof Error ? error : new Error(String(error));
console.warn('[uninstall] Could not read selected runtime from settings, defaulting to worker:', err);
return 'worker';
}
}
function clearServerRuntimeSettings(keys: readonly string[]): void {
let flat: Record<string, unknown> | null;
try {
flat = readFlatSettings(USER_SETTINGS_PATH);
} catch (error: unknown) {
console.warn('[uninstall] Could not read settings for server runtime cleanup:', error instanceof Error ? error.message : String(error));
return;
}
if (!flat) return;
let changed = false;
for (const key of keys) {
if (key in flat) {
delete flat[key];
changed = true;
}
}
if (changed) {
try {
writeSettingsJsonAtomic(USER_SETTINGS_PATH, flat);
} catch (error: unknown) {
console.warn('[uninstall] Could not write settings during server runtime cleanup:', error instanceof Error ? error.message : String(error));
}
}
}View on GitHub (pinned to d8bc9755e7)