thedotmack/claude-mem · info

[install] Could not detect Claude Code version:

Error message

[install] Could not detect Claude Code version:

What it means

detectClaudeCodeVersion() wraps readClaudeCodeVersionOutput() and logs this warning when the probe throws, returning undefined so the installer continues without a recorded Claude Code version. The install itself is not aborted; only version reporting/diagnostics lose that data point.

Solutions

  1. Verify `claude --version` works manually in the same shell as the installer.
  2. Ensure the Claude Code binary directory is on PATH (the installer's PATH-setup step can help).
  3. Reinstall or update Claude Code (`npm install -g @anthropic-ai/claude-code`).
  4. Proceed with install — undefined version is tolerated; re-run install/doctor afterwards to record it.

Example fix

// before
const version = detectClaudeCodeVersion();
// after (pre-check on PATH)
const claudeOnPath = process.env.PATH?.split(':').some(d => existsSync(join(d, 'claude')));
const version = claudeOnPath ? detectClaudeCodeVersion() : undefined;
Defensive patterns

Strategy: fallback

Validate before calling

import { execFileSync } from 'child_process';
function claudeAvailable(): boolean {
  try { execFileSync('claude', ['--version'], { stdio: 'ignore' }); return true; } catch { return false; }
}

Try / catch

try {
  return readClaudeCodeVersionOutput();
} catch (error: unknown) {
  console.warn('[install] Could not detect Claude Code version:', error instanceof Error ? error.message : String(error));
  return undefined; // continue install without version metadata
}

Prevention

When it happens

Trigger: readClaudeCodeVersionOutput throws while locating or running the `claude --version` command — Claude Code not on PATH, command fails, or output parsing encounters an unexpected format.

Common situations: Claude Code installed via a non-standard method (native binary vs npm) so version probing fails; `claude` not on PATH in the installer's shell; recent Claude Code release changed its --version output format; permission-restricted install location.

Related errors


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

Appendix: source

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

    ? (lookupWindowsCommand('claude') ?? 'claude.cmd')
    : 'claude';
  const invocation = buildSpawnSyncInvocation(command, ['--version'], {
    timeout: 5000,
    encoding: 'utf-8',
  });
  const result = spawnSync(invocation.command, invocation.args, invocation.options);
  const output = (result.stdout ?? '').trim();
  if (!output) return undefined;
  // "2.0.14 (Claude Code)" → "2.0.14"
  return output.split(/\s+/)[0].slice(0, 40) || undefined;
}

function detectClaudeCodeVersion(): string | undefined {
  try {
    return readClaudeCodeVersionOutput();
  } catch (error: unknown) {
    const err = error instanceof Error ? error : new Error(String(error));
    console.warn('[install] Could not detect Claude Code version:', err);
    return undefined;
  }
}

interface TaskDescriptor {
  title: string;
  task: (message: (msg: string) => void) => Promise<string>;
}

async function runTasks(tasks: TaskDescriptor[]): Promise<void> {
  if (isInteractive) {
    await p.tasks(tasks);
  } else {
    for (const t of tasks) {
      const result = await t.task((msg: string) => console.log(`  ${msg}`));
      console.log(`  ${result}`);
    }
  }

View on GitHub (pinned to d8bc9755e7)