thedotmack/claude-mem · warning

[uninstall] Could not read settings for server runtime clean

Error message

[uninstall] Could not read settings for server runtime cleanup:

What it means

clearServerRuntimeSettings() calls readFlatSettings(USER_SETTINGS_PATH) to load the flat settings map before deleting leftover server-runtime keys. If the read throws, it warns and returns, so CLAUDE_MEM_RUNTIME and related server-runtime keys remain in ~/.claude/settings.json after uninstall even though the plugin itself is removed.

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 e2d1df569a)

Solutions

  1. Repair settings.json until a plain JSON.parse succeeds
  2. Re-run `npx claude-mem uninstall` so the server-runtime key cleanup executes
  3. Or delete the CLAUDE_MEM_* keys from ~/.claude/settings.json by hand
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'node:fs';
const settings = `${process.env.HOME}/.claude/settings.json`;
JSON.parse(readFileSync(settings, 'utf8')); // must succeed or server-runtime keys survive uninstall

Type guard

function isErrnoException(error: unknown): error is NodeJS.ErrnoException {
  return error instanceof Error && typeof (error as NodeJS.ErrnoException).code === 'string';
}

Prevention

When it happens

Trigger: `npx claude-mem uninstall` on the server-runtime path when settings.json fails to load: malformed JSON, an unreadable file, or a process-locked file on Windows.

Common situations: The same settings.json corruption sources as the runtime-selection read: hand edits, dotfile sync merge conflicts, backups restored with wrong ownership.

Related errors


AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20). Data as JSON: /api/errors/e6c28c26798bfb18. Report an issue: GitHub.