JuliusBrussee/caveman · error

is unavailable; repair host installation first

Error message

${findAgent(target)?.display_name ?? target} is unavailable; repair host installation first

What it means

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.

Solutions

  1. Install or reinstall the agent so its binary is on PATH (`which <agent>` succeeds), then re-run the command with fix
  2. If the agent was installed via a version manager, activate the correct version/shims in this shell first
  3. 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

Example fix

// before
$ caveman gemini status --fix
Error: Gemini CLI is unavailable; repair host installation first
// after
$ npm install -g @google/gemini-cli && which gemini
$ caveman gemini status --fix
Defensive patterns

Strategy: validation

Validate before calling

const status = await caveman.qwen.status();
if (!status.available) {
  throw new Error('Qwen CLI is not installed/available; install it on PATH before running with --fix');
}

Try / catch

try {
  await caveman.qwen.status({ fix: true });
} catch (err) {
  if (err instanceof Error && err.message.includes('unavailable; repair host installation first')) {
    // install the host CLI first, then re-run with fix
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/9db9c337e70ac71c. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/index.ts:8763

async function nativeDoctor(argv: string[]) {
  const fix = argv.includes("--fix");
  const target = argv.find((arg) => arg !== "--fix");
  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]");
  if (target === "generic") {
    const { host, port } = gatewayHostPort();
    const result = genericIntegrationStatus(await portListening(host, port));
    print({ ...result, repair: result.components.shared_runtime ? "caveman start" : "caveman setup --install", trust: "no host lifecycle hooks" });
    return;
  }
  const before = nativeIntegrationStatus(target);
  let fixResult: "not_needed" | "enabled" | "repaired" | "recovered" | undefined;
  if (fix) {
    if (!before.available && before.transaction_pending) {
      withIntegrationLock(target, () => recoverPendingNativeInstallUnlocked(target));
      fixResult = "recovered";
    } else if (!before.available) {
      throw new Error(`${findAgent(target)?.display_name ?? target} is unavailable; repair host installation first`);
    } else if (!before.installed) {
      enableNative([target]);
      fixResult = "enabled";
    } else if (before.state === "installed") {
      fixResult = "not_needed";
    } else {
      repairNativeAgent(target);
      fixResult = "repaired";
    }
  }
  const result = nativeIntegrationStatus(target);
  print({
    ...result,
    repair: result.installed ? `caveman doctor ${target} --fix` : `caveman enable ${target}`,
    trust: target === "codex" && result.installed ? "review through Codex /hooks" : "native host policy",
    ...(fixResult ? { fix: { attempted: true, result: fixResult } } : {}),
  });
  if (result.state === "degraded" || result.state === "unavailable") process.exitCode = 1;

View on GitHub (pinned to 3ee70a1026)