{"record":{"id":"9db9c337e70ac71c","repo":"JuliusBrussee/caveman","slug":"findagent-target-display-name-target-is-un","errorCode":null,"errorMessage":"${findAgent(target)?.display_name ?? target} is unavailable; repair host installation first","messagePattern":"(.+?) is unavailable; repair host installation first","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":8763,"sourceCode":"\nasync function nativeDoctor(argv: string[]) {\n  const fix = argv.includes(\"--fix\");\n  const target = argv.find((arg) => arg !== \"--fix\");\n  if ((target !== \"claude\" && target !== \"codex\" && target !== \"hermes\" && target !== \"gemini\" && target !== \"opencode\" && target !== \"pi\" && target !== \"aider\" && target !== \"generic\") || argv.length !== (fix ? 2 : 1) || (fix && target === \"generic\")) commandUsage(\"doctor <claude|codex|hermes|gemini|opencode|pi|aider|generic> [--fix]\");\n  if (target === \"generic\") {\n    const { host, port } = gatewayHostPort();\n    const result = genericIntegrationStatus(await portListening(host, port));\n    print({ ...result, repair: result.components.shared_runtime ? \"caveman start\" : \"caveman setup --install\", trust: \"no host lifecycle hooks\" });\n    return;\n  }\n  const before = nativeIntegrationStatus(target);\n  let fixResult: \"not_needed\" | \"enabled\" | \"repaired\" | \"recovered\" | undefined;\n  if (fix) {\n    if (!before.available && before.transaction_pending) {\n      withIntegrationLock(target, () => recoverPendingNativeInstallUnlocked(target));\n      fixResult = \"recovered\";\n    } else if (!before.available) {\n      throw new Error(`${findAgent(target)?.display_name ?? target} is unavailable; repair host installation first`);\n    } else if (!before.installed) {\n      enableNative([target]);\n      fixResult = \"enabled\";\n    } else if (before.state === \"installed\") {\n      fixResult = \"not_needed\";\n    } else {\n      repairNativeAgent(target);\n      fixResult = \"repaired\";\n    }\n  }\n  const result = nativeIntegrationStatus(target);\n  print({\n    ...result,\n    repair: result.installed ? `caveman doctor ${target} --fix` : `caveman enable ${target}`,\n    trust: target === \"codex\" && result.installed ? \"review through Codex /hooks\" : \"native host policy\",\n    ...(fixResult ? { fix: { attempted: true, result: fixResult } } : {}),\n  });\n  if (result.state === \"degraded\" || result.state === \"unavailable\") process.exitCode = 1;","sourceCodeStart":8745,"sourceCodeEnd":8781,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L8745-L8781","documentation":"When `--fix` is requested during status/repair, the CLI only fixes caveman-side state (recovering a pending transaction or enabling). If the agent itself is unavailable (binary missing from PATH / host install broken) and there is no pending transaction to recover, caveman cannot fix the host installation, so it throws and instructs you to repair the host installation first.","triggerScenarios":"Running a status/repair command with fix enabled for an agent where the availability check (`before.available`) is false and `before.transaction_pending` is false — i.e. the agent binary is missing/unusable and there is no pending caveman install transaction to recover.","commonSituations":"Agent uninstalled after enabling the integration; broken install (corrupted binary, version-manager not activated); running caveman in an environment (CI, container, different user) where the agent isn't installed at all.","solutions":["Install or reinstall the agent so its binary is on PATH (`which <agent>` succeeds), then re-run the command with fix","If the agent was installed via a version manager, activate the correct version/shims in this shell first","If you expected a pending transaction, check whether a previous enable crashed and clear/recover it, since the fix path only auto-recovers when transaction_pending is true"],"exampleFix":"// before\n$ caveman gemini status --fix\nError: Gemini CLI is unavailable; repair host installation first\n// after\n$ npm install -g @google/gemini-cli && which gemini\n$ caveman gemini status --fix","handlingStrategy":"validation","validationCode":"const status = await caveman.qwen.status();\nif (!status.available) {\n  throw new Error('Qwen CLI is not installed/available; install it on PATH before running with --fix');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await caveman.qwen.status({ fix: true });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('unavailable; repair host installation first')) {\n    // install the host CLI first, then re-run with fix\n  } else throw err;\n}","preventionTips":["Ensure the agent binary is installed and on PATH before using fix-mode commands","Run caveman commands from the same environment/user where the agent is installed","Check availability via `caveman <agent> status` before passing --fix"],"tags":["cli","path","host-installation","fix-mode"],"backgroundTag":"missing-dependency","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}