BoundaryML/baml · error

artifact not found: {} (expected at {})

Error message

artifact not found: {} (expected at {})

What it means

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.

Source

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

            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))
            } else {
                let dir = workspace_root.join("target/release");
                (dir, native_lib_filename(&lib_name))
            }
        }
    };

    let path = dir.join(&filename);
    if !path.exists() {
        bail!(
            "artifact not found: {} (expected at {})",
            filename,
            path.display()
        );
    }
    Ok(path)
}

/// Resolve the `bin` name for a `kind = "bin"` artifact, defaulting to
/// the package name when unset.
fn bin_name(config: &ArtifactConfig) -> Result<String> {
    if let Some(bin) = &config.bin {
        return Ok(bin.clone());
    }
    Ok(config.require_package()?.to_owned())
}

/// Append the platform executable extension (`.exe` on Windows).

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Run `cargo build --release` in the workspace so the binary exists at target/release.
  2. Compare the filename in the error with your [[bin]] name in Cargo.toml; fix the ArtifactConfig if it mismatches.
  3. If CARGO_TARGET_DIR or a custom target dir is set, unset it or point the gate at the actual target directory.
  4. For cross builds, copy/symlink the artifact from target/<triple>/release into target/release or adjust the tool.

Example fix

// before: bin name mismatch in config\nname = "size-gate-bin"\n// after: match Cargo.toml [[bin]] name\nname = "baml-cli"
Defensive patterns

Strategy: validation

Validate before calling

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}

Prevention

When it happens

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

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

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/58da37a228fd9165. Report an issue: GitHub.