{"record":{"id":"975954c231fa9de3","repo":"can1357/oh-my-pi","slug":"command-join-exited-with-code-exitcode","errorCode":null,"errorMessage":"${command.join(\" \")} exited with code ${exitCode}","messagePattern":"(.+?) exited with code (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/tb/agent.ts","lineNumber":17,"sourceCode":"import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport type { AgentBinaries, GatewayConfig, GuestArch } from \"./types\";\nimport type { TrialVm } from \"./vmon\";\n\nconst REPO_ROOT = path.resolve(import.meta.dir, \"../../../..\");\nconst CODING_AGENT_DIR = path.join(REPO_ROOT, \"packages\", \"coding-agent\");\nconst NATIVES_DIR = path.join(REPO_ROOT, \"packages\", \"natives\", \"native\");\n\nfunction shellQuote(value: string): string {\n\treturn `'${value.replaceAll(\"'\", `'\"'\"'`)}'`;\n}\n\nasync function run(command: string[], cwd?: string): Promise<void> {\n\tconst process = Bun.spawn(command, { cwd, stdout: \"inherit\", stderr: \"inherit\" });\n\tconst exitCode = await process.exited;\n\tif (exitCode !== 0) throw new Error(`${command.join(\" \")} exited with code ${exitCode}`);\n}\n/**\n * Refresh cross-target `pi_natives.linux-<arch>*.node` files in\n * `packages/natives/native/` from the published npm leaf package.\n *\n * The binary build embeds whatever `.node` files sit in that directory; on a\n * non-linux host they are stale local cross-builds that can fail `dlopen`\n * inside task guests (undefined libstdc++ symbols). The matching published\n * leaf is the artifact real installs load, so it is the ground truth for\n * embedding; an unpublished working-tree version fails instead of risking\n * loader/API skew.\n */\nasync function refreshCrossNatives(arches: GuestArch[], version: string): Promise<void> {\n\tfor (const arch of arches) {\n\t\tif (process.platform === \"linux\" && process.arch === arch) continue;\n\t\tconst pkg = `pi-natives-linux-${arch}`;\n\t\tconst response = await fetch(`https://registry.npmjs.org/@oh-my-pi/${pkg}/-/${pkg}-${version}.tgz`);\n\t\tif (!response.ok) throw new Error(`Fetching @oh-my-pi/${pkg}@${version} failed: HTTP ${response.status}`);","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/tb/agent.ts#L1-L35","documentation":"The `run` helper in tb/agent.ts spawns a command via Bun.spawn and throws this error when the process exits with a non-zero code. Stdout/stderr are inherited, so the actual failure output has already been printed; the error just records which command failed and its exit code.","triggerScenarios":"Any command run by `run()` (e.g. `bun scripts/ci-release-build-binaries.ts --targets ...` during prepareAgentBinaries, or other build/setup commands) exits non-zero.","commonSituations":"Binary build script fails due to missing toolchain, compilation errors, OOM, or missing deps; network fetches inside the script fail; wrong working directory passed to `run()`.","solutions":["Inspect the inherited stdout/stderr above the error for the real failure cause","Re-run the failing command manually to reproduce and debug","Ensure required tools (bun, cargo/rust toolchain) are installed and on PATH","Check the command's arguments and cwd are correct for your environment"],"exampleFix":"// before\nawait run([\"bun\", \"scripts/ci-release-build-binaries.ts\", \"--targets\", targets], REPO_ROOT);\n// after — precondition check surfaced to the user\nif (!$which(\"cargo\")) throw new Error(\"cargo is required to build agent binaries\");\nawait run([\"bun\", \"scripts/ci-release-build-binaries.ts\", \"--targets\", targets], REPO_ROOT);","handlingStrategy":"try-catch","validationCode":"// verify prerequisites before spawning\nif (!$which(\"cargo\")) throw new Error(\"cargo not found: required for binary build\");","typeGuard":null,"tryCatchPattern":"try {\n  await run([\"bun\", \"scripts/ci-release-build-binaries.ts\", \"--targets\", targets], REPO_ROOT);\n} catch (err) {\n  // stderr was inherited/printed; add context for the caller\n  throw new Error(`binary build failed: ${err instanceof Error ? err.message : err}`);\n}","preventionTips":["Read the inherited stdout/stderr printed before the throw for the root cause","Pre-check required tools (bun, cargo) are on PATH","Run build commands manually once before automating","Ensure the cwd passed to run() is correct"],"tags":["process","build","exit-code"],"backgroundTag":"nonzero-exit-code","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}