BoundaryML/baml · error
`baml pack` failed for fixture {}
Error message
`baml pack` failed for fixture {} What it means
After spawning `<cli> pack -i <fixture> -o <output>`, a non-zero exit status bails with this message naming the fixture. The actual pack errors are printed by the baml CLI on stderr before this bail is raised.
Source
Thrown at baml_language/crates/tools_size_gate/src/measure.rs:148
let output = pack_output_path(workspace_root, name);
if let Some(parent) = output.parent() {
std::fs::create_dir_all(parent)
.with_context(|| format!("failed to create {}", parent.display()))?;
}
eprintln!(" packing {} -> {}", pack.function, output.display());
let status = Command::new(&cli_path)
.arg("pack")
.arg("--file")
.arg(&fixture)
.arg(&pack.function)
.arg("-o")
.arg(&output)
.current_dir(workspace_root)
.status()
.with_context(|| format!("failed to run {} pack", cli_path.display()))?;
if !status.success() {
bail!("`baml pack` failed for fixture {}", fixture.display());
}
if !output.exists() {
bail!("pack produced no output at {}", output.display());
}
Ok(output)
}
/// Deterministic output path for a packed artifact.
fn pack_output_path(workspace_root: &Path, name: &str) -> PathBuf {
workspace_root
.join("target/size-gate")
.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,View on GitHub (pinned to bd85ce9dee)
Solutions
- Read the baml CLI's stderr output above this message for the root cause
- Run the same pack command manually: <cli> pack -i <fixture> -o <output>
- Fix the fixture's BAML source or any missing generator configuration
- Ensure required env vars/network for codegen are available in CI
Example fix
// before: fixture references missing env
// runtime "python" env { OPENAI_API_KEY }
// after: provide it in the measure environment
OPENAI_API_KEY=sk-... size-gate measure ... Defensive patterns
Strategy: try-catch
Validate before calling
// dry-run the pack command before measuring
let status = std::process::Command::new(&cli_path)
.args(["pack", "-i", &fixture, "-o", "/tmp/probe-output"])
.envs(required_codegen_env())
.status()?;
if !status.success() { eprintln!("pack fails on fixture; see CLI stderr"); std::process::exit(1); } Try / catch
if let Err(e) = run_baml_pack(ws, name, pack) {
if e.to_string().contains("baml pack` failed") {
eprintln!("inspect the baml CLI stderr above; often missing env vars or invalid BAML in the fixture");
}
return Err(e);
} Prevention
- Provide all env vars the fixture's generators need in the measure environment
- Validate fixture BAML files (baml CLI check) before the size run
- Pin the baml CLI version used by the gate
- Test pack locally on the same fixture after BAML schema changes
When it happens
Trigger: The baml CLI's pack command fails on the fixture: invalid BAML source in the fixture, missing referenced generators/clients, or CLI runtime panics during packing.
Common situations: Fixture references a generator requiring env vars not set; BAML schema errors after a language change; incompatible fixture format after a CLI version bump; pack requires network for codegen and CI blocks it.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- `gh {}` failed: {}
- pack produced no output at {}
- compilation failed: {e:?}
- failed to serialize BAML bytecode: {e}
- failed to initialize engine for resolution: {e:?}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/3d81fe728b1c1e61.
Report an issue: GitHub.