{"record":{"id":"9bdc0f8546bfc83a","repo":"abhigyanpatwari/GitNexus","slug":"claude-cli-not-found-install-claude-code-and-ensu","errorCode":null,"errorMessage":"Claude CLI not found. Install Claude Code and ensure `claude` is on PATH.","messagePattern":"Claude CLI not found\\. Install Claude Code and ensure `claude` is on PATH\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/wiki/local-cli-client.ts","lineNumber":103,"sourceCode":"}\n\nexport function resolveLocalCLIConfig(overrides?: Partial<LocalCLIConfig>): LocalCLIConfig {\n  return {\n    model: overrides?.model,\n    workingDirectory: overrides?.workingDirectory,\n    requestTimeoutMs: overrides?.requestTimeoutMs,\n  };\n}\n\nexport async function callClaudeLLM(\n  prompt: string,\n  config: LocalCLIConfig,\n  systemPrompt?: string,\n  options?: CallLLMOptions,\n): Promise<LLMResponse> {\n  const commandInfo = getDetectedCommand('claude');\n  if (!commandInfo) {\n    throw new Error('Claude CLI not found. Install Claude Code and ensure `claude` is on PATH.');\n  }\n\n  const args = ['-p', '--output-format', 'text', '--no-session-persistence'];\n  if (config.model) {\n    args.push('--model', config.model);\n  }\n  const fullPrompt = systemPrompt ? `${systemPrompt}\\n\\n---\\n\\n${prompt}` : prompt;\n\n  const response = await runLocalCLI('claude', commandInfo, args, config, fullPrompt, options);\n  if (!response.content) {\n    throw new Error('claude CLI returned empty output');\n  }\n  return response;\n}\n\nexport async function callCodexLLM(\n  prompt: string,\n  config: LocalCLIConfig,","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/wiki/local-cli-client.ts#L85-L121","documentation":"The wiki `--provider claude` path shells out to the user's local Claude Code CLI. Before running, detectLocalCLI executes `claude --version`; if that fails (binary not on PATH → ENOENT, or non-zero exit), the provider is cached as unavailable and callClaudeLLM throws this immediately. Note it can also fire when the binary exists but --version exits non-zero (e.g. broken install), with a warning logged.","triggerScenarios":"Running `gitnexus wiki --provider claude` without Claude Code installed; `claude` not on PATH in the current shell/CI container; claude installed via a version manager whose shims aren't in PATH for this process; broken install where `claude --version` errors.","commonSituations":"CI runners assuming the CLI is preinstalled; nvm/asdf PATH not loaded in non-interactive shells; Windows installs without PATH entry; running in a container where only the Node API key flow was set up.","solutions":["Install Claude Code and verify `claude --version` works in the same shell/environment you run gitnexus from","Fix PATH: ensure the claude binary directory (e.g. ~/.local/bin or npm global bin) is exported in the environment","Once installed, authenticate (`claude` login) so the CLI can answer prompts","If you don't want the local CLI, switch to an HTTP provider: `--provider openai|azure|minimax --api-key ...`"],"exampleFix":"# before\ngitnexus wiki --provider claude   # claude: not found\n\n# after\nnpm install -g @anthropic-ai/claude-code\nclaude --version\ngitnexus wiki --provider claude","handlingStrategy":"validation","validationCode":"import { execFileSync } from 'child_process';\nfunction claudeCliAvailable(): boolean {\n  try { execFileSync('claude', ['--version'], { stdio: 'ignore' }); return true; }\n  catch { return false; }\n}\nif (!claudeCliAvailable()) throw new Error('Install Claude Code first');","typeGuard":"function claudeCliAvailable(): boolean {\n  try { execFileSync('claude', ['--version'], { stdio: 'ignore' }); return true; }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  await callClaudeLLM(prompt, config);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('Claude CLI not found')) {\n    // fall back to an HTTP provider instead of the local CLI\n    return callLLM(prompt, httpConfig);\n  }\n  throw err;\n}","preventionTips":["Pre-flight local CLI providers with `<cmd> --version` in setup scripts","In CI, install the CLI and import auth state as an explicit pipeline step","Provide an HTTP-provider fallback path when the local CLI is absent"],"tags":["llm","claude-code","cli-not-found","path","gitnexus"],"backgroundTag":"cli-not-found","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}