{"record":{"id":"f5929947e14bafe8","repo":"nikivdev/code","slug":"moon-build-output-directory-missing","errorCode":null,"errorMessage":"moon build output directory missing: {}","messagePattern":"moon build output directory missing: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai_tasks.rs","lineNumber":591,"sourceCode":"    }\n    if version.is_empty() {\n        return None;\n    }\n    if let Some(parent) = cache_file.parent() {\n        let _ = fs::create_dir_all(parent);\n    }\n    let _ = fs::write(&cache_file, format!(\"{version}\\n\"));\n    Some(version.into_bytes())\n}\n\nfn find_built_binary(workspace_dir: &Path) -> Result<PathBuf> {\n    let build_dir = workspace_dir\n        .join(\"_build\")\n        .join(\"native\")\n        .join(\"release\")\n        .join(\"build\");\n    if !build_dir.exists() {\n        bail!(\n            \"moon build output directory missing: {}\",\n            build_dir.display()\n        );\n    }\n\n    if let Some(name) = moon_mod_package_name(workspace_dir)? {\n        let candidates = [\n            build_dir.join(format!(\"{name}.exe\")),\n            build_dir.join(name.clone()),\n        ];\n        for candidate in candidates {\n            if candidate.is_file() {\n                return Ok(candidate);\n            }\n        }\n    }\n\n    let mut fallback = None;","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai_tasks.rs#L573-L609","documentation":"Raised by find_built_binary (called from build_task_cached) in src/ai_tasks.rs when the expected moon build output directory `<workspace>/_build/native/release/build` does not exist. This means moon build either never ran successfully or wrote output elsewhere.","triggerScenarios":"build_task_cached reports a successful moon build (or skips it) but find_built_binary cannot find the _build/native/release/build directory — e.g. build ran in debug mode, a different backend, or a cleaned workspace.","commonSituations":"moon built with a different profile/backend so the release/native path differs; _build deleted after build; running on a platform where moon emits a different layout; version changes in moon output paths.","solutions":["Run `moon build` (release/native target) in the workspace first, then retry","Check that _build/native/release/build exists after building; adjust the moon build flags to produce a native release build","Clean stale state (remove _build) and rebuild if a moon version change altered the layout"],"exampleFix":"// before\n// assuming binary exists right after build\nlet artifact = build_task_cached(task, root, false)?;\n// after\nrun_moon_build(root)?; // ensure `moon build` completed with release/native output\nassert!(root.join(\"_build/native/release/build\").exists());\nlet artifact = build_task_cached(task, root, false)?;","handlingStrategy":"validation","validationCode":"let build_dir = root.join(\"_build\").join(\"native\").join(\"release\").join(\"build\");\nif !build_dir.exists() {\n    eprintln!(\"run `moon build` first; {} missing\", build_dir.display());\n}","typeGuard":null,"tryCatchPattern":"match build_task_cached(task, root, false) {\n    Ok(a) => Ok(a),\n    Err(e) if e.to_string().contains(\"moon build output directory missing\") => {\n        // trigger a build then retry once\n        run_moon_build(root)?;\n        build_task_cached(task, root, true)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Ensure moon builds use the native/release profile matching the expected _build layout","Never delete _build between build and cached-run steps","After moon upgrades, verify the output directory layout still matches"],"tags":["moon","missing-directory","build-output","filesystem"],"backgroundTag":"missing-build-output","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}