thedotmack/claude-mem · warning

[uninstall] Could not read selected runtime from settings, d

Error message

[uninstall] Could not read selected runtime from settings, defaulting to worker:

What it means

During uninstall, readSelectedRuntime() loads ~/.claude/settings.json through SettingsDefaultsManager.loadFromFile to decide which teardown to run (worker vs server runtime, issue #2568). If loading throws, the warning prints and the function returns 'worker', so the server-runtime teardown (clearing CLAUDE_MEM server keys and the Docker compose guidance) is skipped even when the server runtime was installed.

Source

Thrown at src/npx-cli/commands/uninstall.ts:37

import { writeJsonFileAtomic as writeSettingsJsonAtomic } from '../../shared/atomic-json.js';
import { shutdownWorkerAndWait } from '../../services/install/shutdown-helper.js';
import {
  normalizeRuntimeFlag,
  SERVER_RUNTIME_SETTINGS_KEYS,
  type InstallRuntimeId,
} from './server-runtime-setup.js';
import { captureCliEvent } from '../../services/telemetry/cli-telemetry.js';

// #2568 — read the runtime the operator installed so uninstall can dispatch to
// 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;

View on GitHub (pinned to e2d1df569a)

Solutions

  1. Validate the settings file by running node with JSON.parse on ~/.claude/settings.json and fix whatever it reports
  2. Fix ownership and permissions on the file (chown to your user, chmod u+r)
  3. If the server runtime was in use, manually remove the leftover CLAUDE_MEM_* server keys from settings.json after uninstall finishes
  4. Re-run `npx claude-mem uninstall` once the file parses
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'node:fs';
// Before uninstall: settings.json must parse, or runtime selection falls back to worker
const settings = `${process.env.HOME}/.claude/settings.json`;
JSON.parse(readFileSync(settings, 'utf8')); // throws early if the file is corrupt

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` while ~/.claude/settings.json is invalid JSON (trailing comma, comments), unreadable (EACCES), or locked by another process on Windows, and the machine actually has the server runtime selected, so its settings survive the uninstall.

Common situations: Hand-edited settings.json with JSON5-style syntax; dotfile merge conflicts; permissions changed after restoring a backup; a running Claude Desktop instance holding the file.

Related errors


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