BoundaryML/baml · error

packed artifact not found (expected at {})

Error message

packed artifact not found (expected at {})

What it means

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.

Source

Thrown at baml_language/crates/tools_size_gate/src/measure.rs:179

        .join(exe_filename(name))
}

/// Find the built artifact in the target directory (public for --no-build mode).
pub(crate) fn locate_artifact_public(
    workspace_root: &Path,
    name: &str,
    config: &ArtifactConfig,
) -> Result<PathBuf> {
    locate_artifact(workspace_root, name, config)
}

/// Find the built artifact in the target directory.
fn locate_artifact(workspace_root: &Path, name: &str, config: &ArtifactConfig) -> Result<PathBuf> {
    let (dir, filename) = match config.kind {
        ArtifactKind::Pack => {
            let path = pack_output_path(workspace_root, name);
            if !path.exists() {
                bail!("packed artifact not found (expected at {})", path.display());
            }
            return Ok(path);
        }
        ArtifactKind::Bin => {
            let dir = workspace_root.join("target/release");
            (dir, exe_filename(&bin_name(config)?))
        }
        ArtifactKind::Cdylib => {
            let package = config.require_package()?;
            let lib_name = resolve_lib_name(workspace_root, package)?;
            if config.is_wasm() {
                let dir = workspace_root.join("target/wasm32-unknown-unknown/release");
                // WASM cdylib output is `<lib_name>.wasm` (the resolved lib
                // target name, which may differ from the package name).
                (dir, format!("{lib_name}.wasm"))
            } else if let Some(target) = &config.target {
                let dir = workspace_root.join(format!("target/{target}/release"));
                (dir, native_lib_filename(&lib_name))

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Run the pack/build step (e.g. `cargo dist build`) so the bundle exists before invoking the size gate.
  2. Verify the expected path printed in the message exists; if not, check pack_output_path matches your cargo-dist config (output dir / bundle formats).
  3. Confirm workspace_root is correct and the artifact name matches the config.
  4. Clean stale state: remove target/ dist caches and rebuild if paths changed between cargo-dist versions.

Example fix

// before: run gate before packing\nsize_gate --check\n// after: build artifacts first\ncargo dist build && size_gate --check
Defensive patterns

Strategy: validation

Validate before calling

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}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/7f306bdf24ee3d9d. Report an issue: GitHub.