thedotmack/claude-mem · warning

[uninstall] Could not read ${cacheRoot}:

Error message

[uninstall] Could not read ${cacheRoot}:

What it means

removeStrayClaudeMemPaths() lists ~/.cache/claude-cli-nodejs (the Claude CLI per-project cache) to find mcp-logs-plugin-claude-mem-* entries. If readdirSync on the cache root fails, it warns with projectDirs empty and skips the entire MCP log cleanup sweep.

Source

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

    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) {
        console.warn(`[uninstall] Could not read ${projectPath}:`, error instanceof Error ? error.message : String(error));
        continue;
      }
      for (const entry of logEntries) {
        if (!entry.startsWith('mcp-logs-plugin-claude-mem-')) continue;
        const logPath = join(projectPath, entry);
        try {
          rmSync(logPath, { recursive: true, force: true });
          removedCount++;
        } catch (error: unknown) {
          console.warn(`[uninstall] Could not remove ${logPath}:`, error instanceof Error ? error.message : String(error));

View on GitHub (pinned to e2d1df569a)

Solutions

  1. Run sudo chown -R $(whoami) ~/.cache/claude-cli-nodejs and re-run uninstall
  2. Or remove the logs manually: find ~/.cache/claude-cli-nodejs -maxdepth 2 -name 'mcp-logs-plugin-claude-mem-*' -exec rm -rf {} +
  3. Ignore it: these are only stale MCP log directories
Defensive patterns

Strategy: validation

Validate before calling

import { accessSync, constants } from 'node:fs';
const cacheRoot = `${process.env.HOME}/.cache/claude-cli-nodejs`;
try { accessSync(cacheRoot, constants.R_OK); }
catch { /* fix ownership of ~/.cache before uninstall or the log sweep is skipped */ }

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` when ~/.cache/claude-cli-nodejs is unreadable (ownership or permission changes, XDG_CACHE_HOME oddities) or disappears mid-run.

Common situations: Cache directories created by a different user or by snap/flatpak-scoped Claude; permission resets on ~/.cache; home directories on network storage with intermittent access.

Related errors


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