thedotmack/claude-mem · warning

[uninstall] Could not write settings during server runtime c

Error message

[uninstall] Could not write settings during server runtime cleanup:

What it means

After deleting server-runtime keys from the flat settings map, clearServerRuntimeSettings() persists the map with writeSettingsJsonAtomic(USER_SETTINGS_PATH, flat). If that atomic write throws (EACCES/EPERM, ENOSPC, a Windows file lock, or a rename failure), the warning prints and the key deletions are effectively lost: stale CLAUDE_MEM_* server keys remain in settings.json while uninstall continues.

Source

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

  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));
    }
  }
}

function removeMarketplaceDirectory(): boolean {
  const marketplaceDir = marketplaceDirectory();
  if (existsSync(marketplaceDir)) {
    rmSync(marketplaceDir, { recursive: true, force: true });
    return true;
  }
  return false;
}

function removeCacheDirectory(): boolean {
  const cacheDirectory = join(pluginsDirectory(), 'cache', 'thedotmack', 'claude-mem');
  if (existsSync(cacheDirectory)) {
    rmSync(cacheDirectory, { recursive: true, force: true });
    return true;

View on GitHub (pinned to e2d1df569a)

Solutions

  1. Close Claude Desktop/Code and any editor holding ~/.claude/settings.json, then re-run `npx claude-mem uninstall`
  2. Fix ownership and permissions: sudo chown $(whoami) ~/.claude/settings.json && chmod u+w ~/.claude/settings.json
  3. Free disk space if the write failed with ENOSPC
  4. If the write keeps failing, delete the CLAUDE_MEM_* keys from settings.json manually
Defensive patterns

Strategy: validation

Validate before calling

import { accessSync, constants } from 'node:fs';
const settings = `${process.env.HOME}/.claude/settings.json`;
try {
  accessSync(settings, constants.W_OK); // predict the atomic-write failure before uninstall
} catch {
  // fix ownership/permissions or close the app holding the file
}

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: Uninstall reaches server-runtime cleanup while settings.json is read-only or owned by another user, the disk is full, or Claude Desktop / an editor / antivirus holds the file with an exclusive lock on Windows.

Common situations: Running Claude Code while uninstalling; Windows indexer or antivirus locking settings.json; ENOSPC on a full home partition; two uninstalls racing on the same file.

Related errors


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