{"record":{"id":"700327a4765066a5","repo":"astrid-runtime/astrid","slug":"astrid-build-failed-with-exit-code","errorCode":null,"errorMessage":"astrid-build failed with exit code {}","messagePattern":"astrid-build failed with exit code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/capsule/install.rs","lineNumber":588,"sourceCode":"        .status()\n        .context(\"Failed to spawn git clone\")?;\n\n    if !status.success() {\n        bail!(\"Failed to clone repository from GitHub.\");\n    }\n\n    let output_dir = tmp_dir.path().join(\"dist\");\n    std::fs::create_dir_all(&output_dir)?;\n\n    let build_bin = crate::bootstrap::find_companion_binary(\"astrid-build\")?;\n    let build_status = std::process::Command::new(build_bin)\n        .arg(clone_dir.to_str().context(\"Invalid clone dir path\")?)\n        .arg(\"--output\")\n        .arg(output_dir.to_str().context(\"Invalid output dir path\")?)\n        .status()\n        .context(\"Failed to run astrid-build\")?;\n    if !build_status.success() {\n        bail!(\n            \"astrid-build failed with exit code {}\",\n            build_status.code().unwrap_or(1)\n        );\n    }\n\n    // Surface (not swallow) a per-entry read error rather than silently\n    // dropping a file with `filter_map(Result::ok)` — a transient I/O or\n    // permissions error on one entry should be reported, not hide a capsule\n    // the operator expects to be installed.\n    let mut produced: Vec<std::path::PathBuf> = Vec::new();\n    for entry in std::fs::read_dir(&output_dir)? {\n        let entry = match entry {\n            Ok(e) => e,\n            Err(err) => {\n                eprintln!(\"warning: skipping unreadable build-output entry: {err}\");\n                continue;\n            },\n        };","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/capsule/install.rs#L570-L606","documentation":"After a successful clone, `clone_and_build` invokes the companion binary `astrid-build` (via `find_companion_binary`) to build the capsule from source, and bails with this message when the build subprocess exits non-zero. The exit code is surfaced via `status.code().unwrap_or(1)` so callers can see how the build failed; the build tool's own output is on stderr.","triggerScenarios":"Installing a capsule from GitHub source when the `astrid-build` process terminates with a non-zero exit code — e.g. compilation error in the capsule source, missing build dependencies, unsupported capsule layout, or the process was killed by a signal (code defaults to 1).","commonSituations":"The cloned repo's capsule source doesn't compile (version mismatch with local toolchain); `astrid-build` binary is present but incompatible/outdated; missing system dependencies required by the capsule build; OOM kill during build (no exit code → reported as 1).","solutions":["Re-run the install with build output visible and inspect `astrid-build`'s stderr for the actual compile/build error","Update the `astrid-build` companion binary to a version matching the capsule source's expected build tooling","Build the capsule manually in the cloned temp dir with `astrid-build` to iterate on the underlying build error","Install missing system/toolchain dependencies the capsule build requires, or fix the capsule source itself if you maintain it"],"exampleFix":"// before: stale astrid-build can't compile the capsule\n$ astrid capsule install github:org/repo\nastrid-build failed with exit code 101\n// after: update the companion binary, then retry\n$ astrid bootstrap update astrid-build\n$ astrid capsule install github:org/repo","handlingStrategy":"try-catch","validationCode":"// Ensure astrid-build companion binary exists and works before install\nlet bin = find_companion_binary(\"astrid-build\")?;\nlet ok = std::process::Command::new(bin)\n    .arg(\"--version\")\n    .status()\n    .map(|s| s.success())\n    .unwrap_or(false);\nif !ok { eprintln!(\"astrid-build missing or broken; update it before installing from source\"); }","typeGuard":null,"tryCatchPattern":"match clone_and_build(url, ...) {\n    Ok(id) => proceed(id),\n    Err(e) if e.to_string().starts_with(\"astrid-build failed with exit code\") => {\n        // rerun astrid-build manually on the cloned source to capture\n        // the full compiler/build diagnostic from stderr\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep the `astrid-build` companion binary updated to the version the capsule source expects","Ensure the build toolchain (compiler, system libs) the capsule needs is installed before source installs","Run source-based installs with stderr visible so the underlying build error is captured","Test-build capsules you maintain in CI so broken sources never reach consumers"],"tags":["build","subprocess","capsule","astrid-build"],"backgroundTag":"git-command-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}