JuliusBrussee/caveman · warning

empty version output

Error message

empty version output

What it means

runtimeVersionDiagnostic parses the trimmed stdout of a version probe (JSON containing version and optionally binary_release). If the output is empty after trimming, it throws "empty version output" because a version probe that printed nothing cannot yield a diagnostic string.

Solutions

  1. Run the runtime's version command manually and inspect both stdout and stderr to find why nothing printed.
  2. Reinstall or repair the runtime CLI (e.g. re-run the engine/runtime install step).
  3. Check the stderr-captured error message nearby in the version flow (safeDiagnostic) for the root cause.
  4. Ensure the runtime binary on PATH is the correct one (not a stub or shim that suppresses output).

Example fix

// before (binary prints to stderr)
$ runtime --version 2>/dev/null
(nothing)
// after: reinstall runtime so `runtime --version` prints JSON like {"version":"1.2.3"}
Defensive patterns

Strategy: try-catch

Validate before calling

function assertNonEmptyStdout(stdout) {
  if (typeof stdout !== "string" || stdout.trim() === "") {
    throw new Error("runtime version probe produced no stdout; check the binary installation");
  }
}

Type guard

function hasVersionPayload(v) { return typeof v === "object" && v !== null && typeof v.version === "string" && v.version.trim() !== ""; }

Try / catch

try {
  const diag = runtimeVersionDiagnostic(stdout);
} catch (e) {
  if (e.message === "empty version output") {
    console.error("Runtime CLI printed nothing on version probe; verify installation and run the command manually to see stderr");
  } else throw e;
}

Prevention

When it happens

Trigger: The runtime CLI version command exits but writes nothing to stdout (crashed early, output redirected to stderr, or the binary is broken); doctor/version then calls runtimeVersionDiagnostic with "".

Common situations: A broken or partially installed runtime binary; a wrapper script swallowing stdout; an old runtime whose version output is on stderr instead of stdout.

Related errors


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

Appendix: source

Thrown at packages/agent/src/cli.ts:431

function compareNodeVersion(current: string, minimum: string): number {
  const parse = (value: string) => value.split(".").slice(0, 3).map((part) => Number(part));
  const left = parse(current);
  const right = parse(minimum);
  for (let index = 0; index < 3; index++) {
    const difference = (left[index] ?? 0) - (right[index] ?? 0);
    if (difference !== 0) return difference;
  }
  return 0;
}

function safeDiagnostic(error: unknown): string {
  const value = error instanceof Error ? error.message : String(error);
  return value.replace(/[\r\n]+/g, " ").slice(0, 512);
}

function runtimeVersionDiagnostic(stdout: string): string {
  const value = stdout.trim();
  if (value === "") throw new Error("empty version output");
  try {
    const parsed = JSON.parse(value) as { version?: unknown; binary_release?: unknown };
    if (typeof parsed.version === "string" && parsed.version.trim() !== "") {
      const release = typeof parsed.binary_release === "string" && parsed.binary_release.trim() !== ""
        ? ` (${parsed.binary_release.trim()})`
        : "";
      return `caveman ${parsed.version.trim()}${release}`;
    }
  } catch {
    // Older CLIs may return one plain version line.
  }
  return value.replace(/[\r\n]+/g, " ").slice(0, 256);
}

function credentialForModel(model: string): { name: string; available: boolean } {
  const provider = model.split("/", 1)[0];
  if (provider === "anthropic") {
    return { name: "ANTHROPIC_API_KEY", available: Boolean(process.env.ANTHROPIC_API_KEY) };

View on GitHub (pinned to 3ee70a1026)