{"record":{"id":"9b50f6275d0d554e","repo":"thedotmack/claude-mem","slug":"uninstall-could-not-read-filepath","errorCode":null,"errorMessage":"[uninstall] Could not read ${filePath}:","messagePattern":"\\[uninstall\\] Could not read (.+?):","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/npx-cli/commands/uninstall.ts","lineNumber":117,"sourceCode":"}\n\nfunction stripLegacyClaudeMemAlias(): void {\n  const home = homedir();\n  const candidateFiles = [\n    join(home, '.bashrc'),\n    join(home, '.zshrc'),\n    join(home, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1'),\n  ];\n\n  const aliasLineRegex = /^\\s*alias\\s+claude-mem\\s*=/;\n\n  for (const filePath of candidateFiles) {\n    if (!existsSync(filePath)) continue;\n    let content: string;\n    try {\n      content = readFileSync(filePath, 'utf-8');\n    } catch (error: unknown) {\n      console.warn(`[uninstall] Could not read ${filePath}:`, error instanceof Error ? error.message : String(error));\n      continue;\n    }\n    const lines = content.split('\\n');\n    const filtered = lines.filter((line) => !aliasLineRegex.test(line));\n    if (filtered.length === lines.length) continue; \n    try {\n      writeFileSync(filePath, filtered.join('\\n'));\n      console.error(`Removed legacy claude-mem alias from ${filePath}`);\n    } catch (error: unknown) {\n      console.warn(`[uninstall] Could not rewrite ${filePath}:`, error instanceof Error ? error.message : String(error));\n    }\n  }\n}\n\nexport function removeFromClaudeSettings(): void {\n  const settings = readJsonSafe<Record<string, any>>(claudeSettingsPath(), {});\n  let dirty = false;\n","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/npx-cli/commands/uninstall.ts#L99-L135","documentation":"Uninstall scans shell rc files (~/.bashrc, ~/.zshrc, and the PowerShell profile) for legacy `alias claude-mem =` lines. If readFileSync fails on one candidate file, it warns and skips to the next file, so that file keeps its claude-mem alias after uninstall.","triggerScenarios":"`npx claude-mem uninstall` when an rc file exists but cannot be read: root-owned after a sudo edit, mode 000 or owned by another user, a dangling symlink, or an I/O error from a failing disk.","commonSituations":"Dotfiles managed by root or another account; rc files symlinked into a private dotfiles repo with restrictive permissions; managed corporate machines.","solutions":["Check the file named in the message: ls -l <filePath>","Fix it: sudo chown $(whoami) <filePath> && chmod u+rw <filePath>","Re-run `npx claude-mem uninstall`, or delete the `alias claude-mem =` line yourself"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { accessSync, constants } from 'node:fs';\nfor (const rc of [`${process.env.HOME}/.bashrc`, `${process.env.HOME}/.zshrc`]) {\n  try { accessSync(rc, constants.R_OK); }\n  catch { /* fix perms before uninstall or the alias removal will skip this file */ }\n}","typeGuard":"function isErrnoException(error: unknown): error is NodeJS.ErrnoException {\n  return error instanceof Error && typeof (error as NodeJS.ErrnoException).code === 'string';\n}","tryCatchPattern":null,"preventionTips":["Keep shell rc files owned and readable by your user","Never edit dotfiles with sudo","After uninstall, grep rc files for 'claude-mem' to confirm the alias removal ran"],"tags":["uninstall","shell-config","alias","filesystem"],"backgroundTag":"file-read-permission-denied","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}