{"record":{"id":"7f306bdf24ee3d9d","repo":"BoundaryML/baml","slug":"packed-artifact-not-found-expected-at","errorCode":null,"errorMessage":"packed artifact not found (expected at {})","messagePattern":"packed artifact not found \\(expected at (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/tools_size_gate/src/measure.rs","lineNumber":179,"sourceCode":"        .join(exe_filename(name))\n}\n\n/// Find the built artifact in the target directory (public for --no-build mode).\npub(crate) fn locate_artifact_public(\n    workspace_root: &Path,\n    name: &str,\n    config: &ArtifactConfig,\n) -> Result<PathBuf> {\n    locate_artifact(workspace_root, name, config)\n}\n\n/// Find the built artifact in the target directory.\nfn locate_artifact(workspace_root: &Path, name: &str, config: &ArtifactConfig) -> Result<PathBuf> {\n    let (dir, filename) = match config.kind {\n        ArtifactKind::Pack => {\n            let path = pack_output_path(workspace_root, name);\n            if !path.exists() {\n                bail!(\"packed artifact not found (expected at {})\", path.display());\n            }\n            return Ok(path);\n        }\n        ArtifactKind::Bin => {\n            let dir = workspace_root.join(\"target/release\");\n            (dir, exe_filename(&bin_name(config)?))\n        }\n        ArtifactKind::Cdylib => {\n            let package = config.require_package()?;\n            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))","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/tools_size_gate/src/measure.rs#L161-L197","documentation":"The size-gate tool locates a built release artifact in the target directory. For `Pack` artifacts (cargo-dist bundles), it computes the expected output path via pack_output_path and bails with this message when that file does not exist on disk. It means the packing step either never ran or wrote output to a different location.","triggerScenarios":"Calling build_artifact or locate_artifact_public for an artifact whose ArtifactKind is Pack, before `cargo dist build` (or equivalent pack step) has produced the bundle at the expected path.","commonSituations":"Running the size gate on a fresh checkout without building; running only the bin build in CI; cargo-dist version change moving bundle output paths; wrong workspace_root passed so paths are computed relative to the wrong directory.","solutions":["Run the pack/build step (e.g. `cargo dist build`) so the bundle exists before invoking the size gate.","Verify the expected path printed in the message exists; if not, check pack_output_path matches your cargo-dist config (output dir / bundle formats).","Confirm workspace_root is correct and the artifact name matches the config.","Clean stale state: remove target/ dist caches and rebuild if paths changed between cargo-dist versions."],"exampleFix":"// before: run gate before packing\\nsize_gate --check\\n// after: build artifacts first\\ncargo dist build && size_gate --check","handlingStrategy":"validation","validationCode":"let expected = pack_output_path(workspace_root, name);\\nif !expected.exists() {\\n    return Err(anyhow!(\"packed artifact missing at {}; run cargo dist build first\", expected.display()));\\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run the pack step (cargo dist build) before the size gate.","Assert artifact paths exist in CI before invoking the gate.","Pin cargo-dist version so bundle output paths stay stable.","Log the computed expected path early for debugging."],"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"}