thedotmack/claude-mem · info

[install] Could not detect Claude Code version:

Error message

[install] Could not detect Claude Code version:

What it means

A console.warn from the installer: detectClaudeCodeVersion() wraps readClaudeCodeVersionOutput(), which spawns `claude --version` and takes the first whitespace token as the version. Any throw — usually spawn ENOENT because Claude Code is not yet installed — is caught, logged here, and the version is treated as unknown (undefined). This is an expected, best-effort path during first-time installs.

Source

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

    ? (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 e2d1df569a)

Solutions

  1. If Claude Code isn't installed yet, let the installer's Claude Code step run — the warning is harmless at that stage
  2. If it IS installed, ensure `claude --version` works in the same shell (check PATH, run hash -r)
  3. Re-run the installer after PATH is fixed to get correct version-aware configuration

Example fix

# before
$ npx claude-mem install
[install] Could not detect Claude Code version: Error: spawn claude ENOENT

# after
$ exec $SHELL && claude --version   # confirm it resolves
$ npx claude-mem install            # version detected, no warning
Defensive patterns

Strategy: fallback

Validate before calling

import { spawnSync } from 'node:child_process';
function claudeInstalled(): boolean {
  try { return spawnSync('claude', ['--version']).status === 0; } catch { return false; }
}

Prevention

When it happens

Trigger: Running `npx claude-mem install` on a machine that does not yet have the `claude` CLI (the installer offers to install it precisely because of this); or claude exists but is not on PATH for this shell; or the binary hangs/errors on --version.

Common situations: Brand-new machine bootstrap where claude-mem is installed before Claude Code itself; claude installed via a version manager whose shims are not on PATH in non-interactive shells; the warning appearing right before the installer's 'install Claude Code' task.

Related errors


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