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
- Verify `claude --version` works manually in the same shell as the installer.
- Ensure the Claude Code binary directory is on PATH (the installer's PATH-setup step can help).
- Reinstall or update Claude Code (`npm install -g @anthropic-ai/claude-code`).
- 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
- Ensure the `claude` binary is on PATH before running the installer.
- Keep Claude Code installed via a supported method (npm global) so version probing works.
- Validate --version output format after Claude Code upgrades.
- Treat undefined version as non-fatal; re-run installer/doctor to re-record it.
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
- Claude Code is not installed. Claude-mem works best in…
- Could not determine Codex CLI version. Continuing; plugin…
- API key prompt cancelled — leaving existing configuration…
- CLAUDE_CODE_PATH is set to
- CLAUDE_CODE_PATH is set to
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)