{"record":{"id":"9d8c1c2f539b41c0","repo":"nikivdev/code","slug":"moon-build-failed-for-ai-task-with-status","errorCode":null,"errorMessage":"moon build failed for AI task '{}' with status {}","messagePattern":"moon build failed for AI task '(.+?)' with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai_tasks.rs","lineNumber":336,"sourceCode":"\n    let mut cmd = Command::new(\"moon\");\n    cmd.arg(\"build\")\n        .arg(\"--target\")\n        .arg(\"native\")\n        .arg(\"--release\");\n    if std::env::var(\"FLOW_AI_TASK_NO_FROZEN\").is_err() {\n        cmd.arg(\"--frozen\");\n    }\n    cmd.arg(&run_path).current_dir(&workspace_dir);\n    let status = cmd.status().with_context(|| {\n        format!(\n            \"failed to build AI task '{}' with moon build (workspace: {})\",\n            task.id,\n            workspace_dir.display()\n        )\n    })?;\n    if !status.success() {\n        bail!(\n            \"moon build failed for AI task '{}' with status {}\",\n            task.id,\n            status\n        );\n    }\n\n    let built_binary = find_built_binary(&workspace_dir)?;\n    fs::copy(&built_binary, &binary_path).with_context(|| {\n        format!(\n            \"failed to copy built binary {} -> {}\",\n            built_binary.display(),\n            binary_path.display()\n        )\n    })?;\n    #[cfg(unix)]\n    {\n        let mut perms = fs::metadata(&binary_path)\n            .with_context(|| format!(\"failed to stat {}\", binary_path.display()))?","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai_tasks.rs#L318-L354","documentation":"Thrown by build_task_cached in src/ai_tasks.rs when the `moon build` invocation for an AI task exits with a non-zero status. The cached binary could not be produced, so the cached-run path aborts.","triggerScenarios":"build_task_cached (via run_task_cached/run_task_cached_output) shells out to moon build in the workspace and the compiler/build fails — syntax errors, missing deps, or target config problems.","commonSituations":"Broken MoonBit source after refactors; unresolved moon module dependencies; mismatched moon toolchain version; stale _build directory interfering.","solutions":["Inspect moon build output above the error for the compiler diagnostics","Run `moon build` manually in the workspace and fix the reported errors","Update/refresh dependencies (moon update) or the moon toolchain, clean _build, and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match build_task_cached(task, root, force) {\n    Ok(a) => Ok(a),\n    Err(e) if e.to_string().contains(\"moon build failed\") => {\n        eprintln!(\"Fix compiler errors shown by moon build output, then retry.\");\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Run `moon build` in CI to catch build breakage early","Keep moon dependencies updated and the toolchain version pinned","Clean _build when the moon version changes"],"tags":["moon","build-failure","compiler","task-runner"],"backgroundTag":"build-command-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}