{"record":{"id":"5c83ec8c76b2ec9d","repo":"thedotmack/claude-mem","slug":"install-could-not-detect-claude-code-version","errorCode":null,"errorMessage":"[install] Could not detect Claude Code version:","messagePattern":"\\[install\\] Could not detect Claude Code version:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/npx-cli/commands/install.ts","lineNumber":94,"sourceCode":"    ? (lookupWindowsCommand('claude') ?? 'claude.cmd')\n    : 'claude';\n  const invocation = buildSpawnSyncInvocation(command, ['--version'], {\n    timeout: 5000,\n    encoding: 'utf-8',\n  });\n  const result = spawnSync(invocation.command, invocation.args, invocation.options);\n  const output = (result.stdout ?? '').trim();\n  if (!output) return undefined;\n  // \"2.0.14 (Claude Code)\" → \"2.0.14\"\n  return output.split(/\\s+/)[0].slice(0, 40) || undefined;\n}\n\nfunction detectClaudeCodeVersion(): string | undefined {\n  try {\n    return readClaudeCodeVersionOutput();\n  } catch (error: unknown) {\n    const err = error instanceof Error ? error : new Error(String(error));\n    console.warn('[install] Could not detect Claude Code version:', err);\n    return undefined;\n  }\n}\n\ninterface TaskDescriptor {\n  title: string;\n  task: (message: (msg: string) => void) => Promise<string>;\n}\n\nasync function runTasks(tasks: TaskDescriptor[]): Promise<void> {\n  if (isInteractive) {\n    await p.tasks(tasks);\n  } else {\n    for (const t of tasks) {\n      const result = await t.task((msg: string) => console.log(`  ${msg}`));\n      console.log(`  ${result}`);\n    }\n  }","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/npx-cli/commands/install.ts#L76-L112","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["If Claude Code isn't installed yet, let the installer's Claude Code step run — the warning is harmless at that stage","If it IS installed, ensure `claude --version` works in the same shell (check PATH, run hash -r)","Re-run the installer after PATH is fixed to get correct version-aware configuration"],"exampleFix":"# before\n$ npx claude-mem install\n[install] Could not detect Claude Code version: Error: spawn claude ENOENT\n\n# after\n$ exec $SHELL && claude --version   # confirm it resolves\n$ npx claude-mem install            # version detected, no warning","handlingStrategy":"fallback","validationCode":"import { spawnSync } from 'node:child_process';\nfunction claudeInstalled(): boolean {\n  try { return spawnSync('claude', ['--version']).status === 0; } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Expect this warning on first-time installs where Claude Code is not yet present — it is normal","Confirm `claude --version` resolves in the installer's shell before re-running for version-aware setup","Use version-manager shims that expose `claude` on PATH in non-interactive shells"],"tags":["installer","claude-code","version-detection","spawn-enoent","best-effort"],"backgroundTag":"version-probe-spawn-failed","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}