{"record":{"id":"5250ccaac965f073","repo":"JuliusBrussee/caveman","slug":"caveman-agent-cave-runtime-did-not-become-ready-a","errorCode":null,"errorMessage":"caveman agent: Cave Runtime did not become ready at ${gatewayURL}; run caveman setup --install","messagePattern":"caveman agent: Cave Runtime did not become ready at (.+?); run caveman setup --install","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/runtime.ts","lineNumber":5269,"sourceCode":"        \"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`,\n    );\n  });\n  child.unref();\n  const deadline = Date.now() + 10_000;\n  while (Date.now() < deadline) {\n    await new Promise((resolve) => setTimeout(resolve, 100));\n    if (startupFailure !== undefined) throw startupFailure;\n    const startedBilling = await runtimeReady(gatewayURL, fetchImpl);\n    if (startedBilling !== undefined) return startedBilling;\n  }\n  throw new Error(\n    `caveman agent: Cave Runtime did not become ready at ${gatewayURL}; run caveman setup --install`,\n  );\n}\n\nasync function runtimeReady(\n  gatewayURL: string,\n  fetchImpl: typeof globalThis.fetch,\n): Promise<GatewayProviderBilling | undefined> {\n  const identity = await gatewayIdentity(gatewayURL, fetchImpl);\n  if (identity === undefined) return undefined;\n  return await localProxyOwned(new URL(gatewayURL)) ? identity.providerBilling : undefined;\n}\n\n// A gateway hostname is loopback only if the traffic can never leave the host.\n// WHATWG URL returns IPv6 literals bracketed (\"[::1]\"), so both forms are\n// checked; 127.0.0.0/8 and 0.0.0.0 all route to localhost and must not be\n// treated as remote (nor as needing https).\nfunction isLoopbackHostname(hostname: string): boolean {","sourceCodeStart":5251,"sourceCodeEnd":5287,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/runtime.ts#L5251-L5287","documentation":"After spawning the Cave Runtime daemon, the agent polls runtimeReady(gatewayURL) until a deadline. If the runtime never becomes ready in time (and no startup failure surfaced), it throws this error advising 'caveman setup --install'. It means the gateway endpoint is not answering readiness checks after the start attempt.","triggerScenarios":"Spawning 'caveman start' then polling /health/ready every 100ms until the deadline expires without a successful readiness response from gatewayURL.","commonSituations":"Runtime daemon crashed silently at startup (stdio is ignored so output is lost); port occupied by another process; gateway installed but never configured; very slow host exceeding the readiness deadline; firewall blocking the local port.","solutions":["Run 'caveman setup --install' to complete installation/configuration of the runtime","Check whether anything else is bound to the gateway port and free it, then retry","Start the runtime manually ('caveman start') to observe its errors, since the daemon's stdio is ignored","Verify the gateway URL/port used by the agent matches the port the runtime actually listens on"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const deadline = Date.now() + 30_000;\nwhile (Date.now() < deadline) {\n  if (await isReady(gatewayURL)) break;\n  await new Promise(r => setTimeout(r, 100));\n}","typeGuard":null,"tryCatchPattern":"try {\n  await startCaveRuntime();\n} catch (e) {\n  if (String(e.message).includes('did not become ready')) {\n    console.error('Run: caveman setup --install');\n  } else throw e;\n}","preventionTips":["Complete caveman setup --install before programmatic starts","Run the daemon under a supervisor with logs captured (the spawn ignores stdio)","Verify no port conflicts on the gateway port before start","Allow generous readiness deadlines on slow hosts/CI"],"tags":["gateway","timeout","startup","process-spawn"],"backgroundTag":"request-timeout","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"}