{"record":{"id":"58da37a228fd9165","repo":"BoundaryML/baml","slug":"artifact-not-found-expected-at","errorCode":null,"errorMessage":"artifact not found: {} (expected at {})","messagePattern":"artifact not found: (.+?) \\(expected at (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/tools_size_gate/src/measure.rs","lineNumber":207,"sourceCode":"            let lib_name = resolve_lib_name(workspace_root, package)?;\n            if config.is_wasm() {\n                let dir = workspace_root.join(\"target/wasm32-unknown-unknown/release\");\n                // WASM cdylib output is `<lib_name>.wasm` (the resolved lib\n                // target name, which may differ from the package name).\n                (dir, format!(\"{lib_name}.wasm\"))\n            } else if let Some(target) = &config.target {\n                let dir = workspace_root.join(format!(\"target/{target}/release\"));\n                (dir, native_lib_filename(&lib_name))\n            } else {\n                let dir = workspace_root.join(\"target/release\");\n                (dir, native_lib_filename(&lib_name))\n            }\n        }\n    };\n\n    let path = dir.join(&filename);\n    if !path.exists() {\n        bail!(\n            \"artifact not found: {} (expected at {})\",\n            filename,\n            path.display()\n        );\n    }\n    Ok(path)\n}\n\n/// Resolve the `bin` name for a `kind = \"bin\"` artifact, defaulting to\n/// the package name when unset.\nfn bin_name(config: &ArtifactConfig) -> Result<String> {\n    if let Some(bin) = &config.bin {\n        return Ok(bin.clone());\n    }\n    Ok(config.require_package()?.to_owned())\n}\n\n/// Append the platform executable extension (`.exe` on Windows).","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/tools_size_gate/src/measure.rs#L189-L225","documentation":"After resolving the directory and filename for a Bin artifact, locate_artifact joins them and checks existence. If the binary is not at <workspace>/target/release/<name> it bails with the artifact name and expected path. This is a pre-flight check so the size gate never measures a missing file.","triggerScenarios":"build_artifact or locate_artifact_public for an ArtifactKind::Bin whose built executable is absent from target/release (wrong bin name, build not run, cross-compilation target dir).","commonSituations":"Typo in bin_name or Cargo.toml [[bin]] name; building with CARGO_TARGET_DIR set to a custom directory; running release checks without `cargo build --release`; cross-compiled binaries landing under target/<triple>/release.","solutions":["Run `cargo build --release` in the workspace so the binary exists at target/release.","Compare the filename in the error with your [[bin]] name in Cargo.toml; fix the ArtifactConfig if it mismatches.","If CARGO_TARGET_DIR or a custom target dir is set, unset it or point the gate at the actual target directory.","For cross builds, copy/symlink the artifact from target/<triple>/release into target/release or adjust the tool."],"exampleFix":"// before: bin name mismatch in config\\nname = \"size-gate-bin\"\\n// after: match Cargo.toml [[bin]] name\\nname = \"baml-cli\"","handlingStrategy":"validation","validationCode":"let bin = workspace_root.join(\"target/release\").join(\"baml-cli\");\\nif !bin.exists() {\\n    return Err(anyhow!(\"release binary missing: {} — run cargo build --release\", bin.display()));\\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `cargo build --release` as a prerequisite step in CI.","Keep artifact config bin names in sync with Cargo.toml [[bin]] entries.","Avoid custom CARGO_TARGET_DIR when using the gate, or account for it.","After cross-compiling, copy artifacts into target/release before measuring."],"tags":["rust","build","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}