{"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":2007,"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  // All claude-mem hooks run via `\"shell\": \"bash\"`; on Windows, Claude Code\n  // resolves that through Git for Windows with no WSL fallback. Surfacing it\n  // here — rather than letting the first hook throw an unbranded error — is\n  // a warning, not a hard stop: the operator may install Git for Windows\n  // after this run and hooks will start working without a reinstall.\n  if (IS_WINDOWS) {","sourceCodeStart":1989,"sourceCodeEnd":2025,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/npx-cli/commands/install.ts#L1989-L2025","documentation":"While printing the install banner, the CLI reads the existing marketplace plugin.json to compare versions. If reading or JSON-parsing that file fails, it logs this warning, leaves existingVersion undefined, and continues — you just lose the 'upgraded from vX' hint. Install itself is unaffected.","triggerScenarios":"Running `npx claude-mem install` when `<marketplaceDir>/plugin/.claude-plugin/plugin.json` is missing, unreadable, or contains invalid JSON.","commonSituations":"First-ever install (no previous plugin.json — most common); partially deleted or corrupted marketplace directory; interrupted previous install left truncated JSON; manual edits to plugin.json.","solutions":["Ignore if this is a first install — the warning is expected and harmless.","If a previous install existed, re-clone/restore the marketplace directory (re-run the marketplace setup or `npx claude-mem install` after removing the corrupted dir).","Validate/fix plugin.json JSON syntax if it was hand-edited, then reinstall."],"exampleFix":"// before: corrupted marketplace plugin.json\n{ \"version\": \"5.2\",  // trailing content / truncation\n// after: delete and reinstall cleanly\nrm -rf ~/.claude/plugins/marketplaces/thedotmack\nnpx claude-mem install","handlingStrategy":"validation","validationCode":"// Verify the plugin manifest exists and parses before install\nimport { existsSync, readFileSync } from 'node:fs';\nconst p = join(marketplaceDir, 'plugin', '.claude-plugin', 'plugin.json');\nif (existsSync(p)) JSON.parse(readFileSync(p, 'utf-8')); // throws early on bad JSON","typeGuard":"function hasVersion(o: unknown): o is { version: string } {\n  return typeof o === 'object' && o !== null && 'version' in o && typeof (o as any).version === 'string';\n}","tryCatchPattern":"try {\n  existingVersion = JSON.parse(readFileSync(pluginJsonPath, 'utf-8')).version;\n} catch {\n  existingVersion = undefined; // non-fatal: skip upgrade-version display\n}","preventionTips":["Don't hand-edit plugin.json","Let installs complete — avoid killing the process mid-write","Expect this warning on first install (no previous manifest)","Reinstall cleanly if the marketplace directory looks corrupted"],"tags":["install","json","version-check","non-fatal"],"backgroundTag":"json-parse-error","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}