thedotmack/claude-mem · warning

[uninstall] Could not read selected runtime from settings…

Error message

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

What it means

During uninstall, readSelectedRuntime loads user settings to determine which runtime (worker/server) was selected so it can be cleaned up. If settings can't be loaded, it logs this warning and defaults to 'worker', so uninstall proceeds with worker cleanup only.

Solutions

  1. Validate ~/.claude/settings.json with a JSON linter and fix syntax errors, then re-run uninstall.
  2. Fix file permissions (chown/chmod) so the current user can read the settings file.
  3. If you know the runtime was 'server', manually clean the server runtime pieces or temporarily set CLAUDE_MEM_RUNTIME correctly before uninstalling.
  4. Proceed with default worker cleanup if worker is what you used — the warning is otherwise harmless.

Example fix

// before: malformed settings
{ "CLAUDE_MEM_RUNTIME": "server", }  // trailing comma
// after: fix JSON
{ "CLAUDE_MEM_RUNTIME": "server" }
npx claude-mem uninstall
Defensive patterns

Strategy: fallback

Validate before calling

// Validate settings before uninstall
import { existsSync } from 'node:fs';
import { readFileSync } from 'node:fs';
if (existsSync(USER_SETTINGS_PATH)) JSON.parse(readFileSync(USER_SETTINGS_PATH, 'utf-8'));

Type guard

function hasRuntimeSetting(s: unknown): s is { CLAUDE_MEM_RUNTIME: string } {
  return typeof s === 'object' && s !== null && 'CLAUDE_MEM_RUNTIME' in s;
}

Try / catch

try {
  const settings = SettingsDefaultsManager.loadFromFile(USER_SETTINGS_PATH);
  return normalizeRuntimeFlag(settings.CLAUDE_MEM_RUNTIME) ?? 'worker';
} catch (error) {
  console.warn('[uninstall] Could not read selected runtime from settings, defaulting to worker:', error);
  return 'worker';
}

Prevention

When it happens

Trigger: Running `claude-mem uninstall` when SettingsDefaultsManager.loadFromFile(USER_SETTINGS_PATH) throws — settings file missing (unexpectedly), unreadable permissions, or malformed JSON.

Common situations: Hand-edited ~/.claude/settings.json with JSON syntax errors; settings file permissions changed (root-owned, read-only); file locked or on a failing disk; partially deleted config directory.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


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

Appendix: 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 d8bc9755e7)