{"record":{"id":"f56f21e4dc77bfa6","repo":"thedotmack/claude-mem","slug":"install-failed-to-read-existing-plugin-version","errorCode":null,"errorMessage":"[install] Failed to read existing plugin version:","messagePattern":"\\[install\\] Failed to read existing plugin version:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/npx-cli/commands/install.ts","lineNumber":1957,"sourceCode":"\n  if (isInteractive) {\n    await playBanner();\n    p.intro(styleText(['bgCyan', 'black'], ' claude-mem install '));\n  } else {\n    console.log('claude-mem install');\n  }\n  const marketplaceDir = marketplaceDirectory();\n  const alreadyInstalled = existsSync(join(marketplaceDir, 'plugin', '.claude-plugin', 'plugin.json'));\n\n  let existingVersion: string | undefined;\n  if (alreadyInstalled) {\n    try {\n      const existingPluginJson = JSON.parse(\n        readFileSync(join(marketplaceDir, 'plugin', '.claude-plugin', 'plugin.json'), 'utf-8'),\n      );\n      existingVersion = existingPluginJson.version ?? undefined;\n    } catch (error: unknown) {\n      console.warn('[install] Failed to read existing plugin version:', error instanceof Error ? error.message : String(error));\n    }\n  }\n\n  const dot = styleText('dim', '·');\n  const segments = [`${styleText('bold', 'claude-mem')} ${styleText('cyan', `v${version}`)}`];\n  if (existingVersion && existingVersion !== version) {\n    segments.push(`installed ${styleText('yellow', `v${existingVersion}`)}`);\n  } else if (existingVersion) {\n    segments.push(styleText('dim', 'reinstall'));\n  }\n  log.info(segments.join(` ${dot} `));\n\n  // An explicit --provider flag wins over the trial funnel: never pitch,\n  // email, poll, or override a provider the operator asked for by name.\n  const trialPairing = options.provider ? null : await promptProTrialOptIn(version);\n\n  if (alreadyInstalled) {\n    if (process.stdin.isTTY) {","sourceCodeStart":1939,"sourceCodeEnd":1975,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/npx-cli/commands/install.ts#L1939-L1975","documentation":"Printed by the installer while it builds the version banner. It first confirms that <marketplaceDir>/plugin/.claude-plugin/plugin.json exists, then runs readFileSync plus JSON.parse on it to learn the already-installed version. When either call throws (truncated or corrupt JSON, EACCES, odd encoding) the warning prints and existingVersion stays undefined, so the banner omits the 'installed vX' / 'reinstall' segment. The install itself is not affected.","triggerScenarios":"Run `npx claude-mem install` (reinstall or upgrade) while plugin.json exists but is unreadable or unparsable: a previously interrupted install left a truncated file, the marketplace directory is root-owned after a one-off sudo install, or the JSON was hand-edited or saved with a broken encoding.","commonSituations":"Killing an install midway and re-running it; sudo installs leaving root-owned files under ~/.claude/plugins/marketplaces; dotfile sync tools producing partial files; a disk-full condition during an earlier plugin.json write.","solutions":["Inspect and validate the file: cat ~/.claude/plugins/marketplaces/thedotmack/plugin/.claude-plugin/plugin.json, then run node with JSON.parse(readFileSync(...)) on it to confirm it parses","Fix ownership and permissions if it is root-owned: sudo chown -R $(whoami) ~/.claude/plugins/marketplaces/thedotmack","If the JSON cannot be repaired, run `npx claude-mem uninstall` and install again so a clean plugin.json is written","Treat the warning as cosmetic if the version banner does not matter: install continues regardless"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\n// Before install: confirm the marketplace plugin.json is readable, valid JSON\nconst pluginJson = `${process.env.HOME}/.claude/plugins/marketplaces/thedotmack/plugin/.claude-plugin/plugin.json`;\ntry {\n  JSON.parse(readFileSync(pluginJson, 'utf8'));\n} catch {\n  // repair or delete plugin.json before running `npx claude-mem install`\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 ~/.claude owned by your user; never run claude-mem install with sudo","If an install is interrupted, uninstall before reinstalling so plugin.json is rewritten clean","Treat plugin.json as build output: do not hand-edit it"],"tags":["install","plugin-metadata","json-parse","filesystem"],"backgroundTag":"corrupted-json-file","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}