thedotmack/claude-mem · warning

[uninstall] Could not remove ${candidate}:

Error message

[uninstall] Could not remove ${candidate}:

What it means

While sweeping npx cache directories, uninstall runs rmSync(recursive, force) on each <hash>/node_modules/claude-mem copy. If the removal throws (EACCES/EPERM, or EBUSY on Windows because a node process still has files open), it warns and continues with the next candidate; that stray copy remains.

Source

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

  const home = homedir();
  let removedCount = 0;

  const npxRoot = join(home, '.npm', '_npx');
  if (existsSync(npxRoot)) {
    let hashDirs: string[] = [];
    try {
      hashDirs = readdirSync(npxRoot);
    } catch (error: unknown) {
      console.warn(`[uninstall] Could not read ${npxRoot}:`, error instanceof Error ? error.message : String(error));
    }
    for (const hashDir of hashDirs) {
      const candidate = join(npxRoot, hashDir, 'node_modules', 'claude-mem');
      if (!existsSync(candidate)) continue;
      try {
        rmSync(candidate, { recursive: true, force: true });
        removedCount++;
      } catch (error: unknown) {
        console.warn(`[uninstall] Could not remove ${candidate}:`, error instanceof Error ? error.message : String(error));
      }
    }
  }

  const cacheRoot = join(home, '.cache', 'claude-cli-nodejs');
  if (existsSync(cacheRoot)) {
    let projectDirs: string[] = [];
    try {
      projectDirs = readdirSync(cacheRoot);
    } catch (error: unknown) {
      console.warn(`[uninstall] Could not read ${cacheRoot}:`, error instanceof Error ? error.message : String(error));
    }
    for (const projectDir of projectDirs) {
      const projectPath = join(cacheRoot, projectDir);
      let logEntries: string[] = [];
      try {
        logEntries = readdirSync(projectPath);
      } catch (error: unknown) {

View on GitHub (pinned to e2d1df569a)

Solutions

  1. Stop running claude-mem and node processes (ps aux | grep claude-mem, lsof +D <candidate>) and re-run uninstall
  2. Fix ownership: sudo chown -R $(whoami) ~/.npm/_npx
  3. Delete the path printed in the message manually: rm -rf <candidate>
Defensive patterns

Strategy: validation

Validate before calling

import { accessSync, constants } from 'node:fs';
// Before uninstall: the npx cache copy must be removable (not locked or read-only)
accessSync(`${process.env.HOME}/.npm/_npx`, constants.R_OK | constants.W_OK); // throws EACCES/EPERM early

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 a claude-mem worker or an npx-spawned process still runs from that cache directory; root-owned files inside _npx; Windows file locks from an indexer or antivirus.

Common situations: Uninstalling without stopping the worker first; leftover processes after a crashed run; sudo-created cache entries.

Related errors


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