thedotmack/claude-mem · warning

[install] Failed to read existing plugin version:

Error message

[install] Failed to read existing plugin version:

What it means

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.

Solutions

  1. Ignore if this is a first install — the warning is expected and harmless.
  2. 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).
  3. Validate/fix plugin.json JSON syntax if it was hand-edited, then reinstall.

Example fix

// before: corrupted marketplace plugin.json
{ "version": "5.2",  // trailing content / truncation
// after: delete and reinstall cleanly
rm -rf ~/.claude/plugins/marketplaces/thedotmack
npx claude-mem install
Defensive patterns

Strategy: validation

Validate before calling

// Verify the plugin manifest exists and parses before install
import { existsSync, readFileSync } from 'node:fs';
const p = join(marketplaceDir, 'plugin', '.claude-plugin', 'plugin.json');
if (existsSync(p)) JSON.parse(readFileSync(p, 'utf-8')); // throws early on bad JSON

Type guard

function hasVersion(o: unknown): o is { version: string } {
  return typeof o === 'object' && o !== null && 'version' in o && typeof (o as any).version === 'string';
}

Try / catch

try {
  existingVersion = JSON.parse(readFileSync(pluginJsonPath, 'utf-8')).version;
} catch {
  existingVersion = undefined; // non-fatal: skip upgrade-version display
}

Prevention

When it happens

Trigger: Running `npx claude-mem install` when `<marketplaceDir>/plugin/.claude-plugin/plugin.json` is missing, unreadable, or contains invalid JSON.

Common situations: 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.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/f56f21e4dc77bfa6. Report an issue: GitHub.

Appendix: source

Thrown at src/npx-cli/commands/install.ts:2007

  if (isInteractive) {
    await playBanner();
    p.intro(styleText(['bgCyan', 'black'], ' claude-mem install '));
  } else {
    console.log('claude-mem install');
  }
  const marketplaceDir = marketplaceDirectory();
  const alreadyInstalled = existsSync(join(marketplaceDir, 'plugin', '.claude-plugin', 'plugin.json'));

  let existingVersion: string | undefined;
  if (alreadyInstalled) {
    try {
      const existingPluginJson = JSON.parse(
        readFileSync(join(marketplaceDir, 'plugin', '.claude-plugin', 'plugin.json'), 'utf-8'),
      );
      existingVersion = existingPluginJson.version ?? undefined;
    } catch (error: unknown) {
      console.warn('[install] Failed to read existing plugin version:', error instanceof Error ? error.message : String(error));
    }
  }

  const dot = styleText('dim', '·');
  const segments = [`${styleText('bold', 'claude-mem')} ${styleText('cyan', `v${version}`)}`];
  if (existingVersion && existingVersion !== version) {
    segments.push(`installed ${styleText('yellow', `v${existingVersion}`)}`);
  } else if (existingVersion) {
    segments.push(styleText('dim', 'reinstall'));
  }
  log.info(segments.join(` ${dot} `));

  // All claude-mem hooks run via `"shell": "bash"`; on Windows, Claude Code
  // resolves that through Git for Windows with no WSL fallback. Surfacing it
  // here — rather than letting the first hook throw an unbranded error — is
  // a warning, not a hard stop: the operator may install Git for Windows
  // after this run and hooks will start working without a reinstall.
  if (IS_WINDOWS) {

View on GitHub (pinned to d8bc9755e7)