{"record":{"id":"e0ebfcdb4c23c42c","repo":"JuliusBrussee/caveman","slug":"caveman-agent-cave-runtime-failed-to-start-err","errorCode":null,"errorMessage":"caveman agent: Cave Runtime failed to start (${error instanceof Error ? error.message : String(error)})","messagePattern":"caveman agent: Cave Runtime failed to start \\((.+?)\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/runtime.ts","lineNumber":5240,"sourceCode":"        `cave_gateway_identity_unverified: non-loopback gateway ${gatewayURL} requires https`,\n      );\n    }\n    const identity = await gatewayIdentity(gatewayURL, fetchImpl);\n    if (identity !== undefined) return identity.providerBilling;\n    throw new Error(\n      `cave_gateway_identity_unverified: ${gatewayURL}/health/ready did not identify as caveman-proxy`,\n    );\n  }\n  const readyBilling = await runtimeReady(gatewayURL, fetchImpl);\n  if (readyBilling !== undefined) return readyBilling;\n\n  const command = process.env.CAVEMAN_CLI_BIN ?? \"caveman\";\n  let startupFailure: Error | undefined;\n  let invocation;\n  try {\n    invocation = portableInvocation(command, [\"start\"], { env: buildRuntimeControlEnv() });\n  } catch (error) {\n    throw new Error(`caveman agent: Cave Runtime failed to start (${error instanceof Error ? error.message : String(error)})`);\n  }\n  const child = spawn(invocation.command, [...invocation.args], {\n    detached: true,\n    windowsHide: true,\n    stdio: \"ignore\",\n    env: buildRuntimeControlEnv(),\n  });\n  child.once(\"error\", (error) => {\n    startupFailure = (error as NodeJS.ErrnoException).code === \"ENOENT\"\n      ? new Error(\n        \"caveman agent: Caveman CLI not found; run npm install, then caveman setup --install\",\n      )\n      : new Error(`caveman agent: Cave Runtime failed to start (${error.message})`);\n  });\n  child.once(\"exit\", (code, signal) => {\n    if (startupFailure !== undefined || code === 0) return;\n    startupFailure = new Error(\n      `caveman agent: Cave Runtime failed to start (caveman start exited ${signal ?? code}); run caveman setup --install`,","sourceCodeStart":5222,"sourceCodeEnd":5258,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/runtime.ts#L5222-L5258","documentation":"When the agent runtime spawns the Cave Runtime daemon ('caveman start'), failures to even construct the portable invocation (e.g. the CLI binary cannot be resolved for the platform) are wrapped into this error. It reports the underlying message so the caller knows the runtime process never launched.","triggerScenarios":"portableInvocation(command, ['start'], ...) throws while building the spawn invocation — typically because the resolved 'caveman' binary is missing or CAVEMAN_CLI_BIN points to a nonexistent/unusable path.","commonSituations":"Caveman CLI not installed or not on PATH; CAVEMAN_CLI_BIN set to a stale path after a reinstall; cross-platform launch (Windows vs POSIX) where the binary name is wrong.","solutions":["Install the Caveman CLI so 'caveman' resolves on PATH (caveman setup --install)","Check/fix the CAVEMAN_CLI_BIN env var to point at the real CLI binary","Run 'caveman start' manually to see the underlying launch failure directly"],"exampleFix":"// before: stale binary path\nexport CAVEMAN_CLI_BIN=/usr/local/bin/caveman-old\n// after\nunset CAVEMAN_CLI_BIN   # or point at the installed binary\nexport CAVEMAN_CLI_BIN=/usr/local/bin/caveman","handlingStrategy":"try-catch","validationCode":"const bin = process.env.CAVEMAN_CLI_BIN ?? 'caveman';\nawait fs.promises.access(bin, fs.constants.X_OK).catch(() => { throw new Error(`CLI not executable: ${bin}`); });","typeGuard":null,"tryCatchPattern":"try {\n  await startCaveRuntime();\n} catch (e) {\n  if (String(e.message).includes('Cave Runtime failed to start')) {\n    console.error('Check CAVEMAN_CLI_BIN / PATH:', e.message);\n  } else throw e;\n}","preventionTips":["Install the CLI via caveman setup --install and verify with 'caveman --version'","Keep CAVEMAN_CLI_BIN accurate across upgrades","Add a startup health check that the CLI binary exists and is executable"],"tags":["process-spawn","cli","startup"],"backgroundTag":"command-not-found","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"}