BoundaryML/baml · error

unsupported pack target `{target_triple}`

Error message

unsupported pack target `{target_triple}`

What it means

`write_executable` embeds packed payload data as a section in the host executable, but it only knows how to patch known binary formats (e.g. ELF, PE, Mach-O — the Mach-O branch is visible in the source). For any other `target_triple` it hits the `else` arm and bails with `unsupported pack target`. This is a hard platform-support boundary, not a validation error: the triple passed validation but no section-writer exists for its format.

Source

Thrown at baml_language/crates/baml_cli/src/pack_command.rs:675

        libsui::Elf::new(host_bytes)
            .append(PACK_SECTION_NAME, data, writer)
            .context("failed to write ELF binary")?;
    } else if target_triple.contains("windows") {
        libsui::PortableExecutable::from(host_bytes)
            .context("failed to parse PE binary")?
            .write_resource(PACK_SECTION_NAME, data.to_vec())
            .context("failed to write PE resource")?
            .build(writer)
            .context("failed to build PE binary")?;
    } else if target_triple.contains("apple-darwin") {
        libsui::Macho::from(host_bytes.to_vec())
            .context("failed to parse Mach-O binary")?
            .write_section(PACK_SECTION_NAME, data.to_vec())
            .context("failed to write Mach-O section")?
            .build_and_sign(writer)
            .context("failed to build Mach-O binary")?;
    } else {
        anyhow::bail!("unsupported pack target `{target_triple}`");
    }
    Ok(())
}
// Tests
// ============================================================================

#[cfg(test)]
mod tests {
    use super::*;

    fn engine_from_source(source: &str) -> BexEngine {
        let snapshot = baml_tests::engine::compile_source(source);
        BexEngine::new(snapshot, Arc::new(sys_native::SysOps::native()), Vec::new())
            .expect("BexEngine::new should succeed")
    }

    /// Build an engine from a multi-file project so we can exercise
    /// namespaced functions (`ns_<name>/foo.baml` → `<name>.foo`). Single

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Pack only for supported desktop targets (Linux ELF, Windows PE, macOS Mach-O).
  2. Cross-check the triple's OS: pack for the target's actual OS rather than an emulator/virtual target like wasm32.
  3. If the triple should be supported, request/await upstream support in the pack command's `write_executable` for that binary format.
  4. As a workaround, distribute the packed binary per-platform instead of trying to pack one universal artifact.

Example fix

// before
$ baml pack wasm32-wasi myFn
// after (pack for a supported platform)
$ baml pack x86_64-unknown-linux-gnu myFn
Defensive patterns

Strategy: validation

Validate before calling

const PACKABLE_TARGETS: &[&str] = &[
    "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu",
    "aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-pc-windows-msvc",
];
if !PACKABLE_TARGETS.contains(&target_triple) {
    eprintln!("target {target_triple} has no section writer; pick one of {PACKABLE_TARGETS:?}");
    std::process::exit(2);
}

Type guard

fn is_packable(triple: &str) -> bool {
    matches!(triple, "x86_64-unknown-linux-gnu" | "aarch64-apple-darwin" | "x86_64-pc-windows-msvc" | _)
        // in real code: explicit list of ELF/PE/Mach-O triples
}

Try / catch

match write_executable(&writer, &data, target_triple) {
    Ok(()) => (),
    Err(e) if e.to_string().starts_with("unsupported pack target") => {
        eprintln!("{e}; pack only Linux/Windows/macOS desktop targets");
        std::process::exit(2);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `baml pack` with a target triple whose executable format has no writer implemented (e.g. WASI, bare-metal, or otherwise exotic targets) reaches `write_executable` via `run_with_reporter` and falls into `anyhow::bail!("unsupported pack target `{target_triple}`")`.

Common situations: Attempting to pack for wasm32/wasi or an embedded target; building on/for a platform the pack toolchain doesn't support yet; a newly added triple that `validate_release_target_triple` accepts but `write_executable` hasn't been extended to handle.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


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