{"record":{"id":"c47766f1b27a0d8e","repo":"BoundaryML/baml","slug":"unsupported-pack-target-target-triple","errorCode":null,"errorMessage":"unsupported pack target `{target_triple}`","messagePattern":"unsupported pack target `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/pack_command.rs","lineNumber":675,"sourceCode":"        libsui::Elf::new(host_bytes)\n            .append(PACK_SECTION_NAME, data, writer)\n            .context(\"failed to write ELF binary\")?;\n    } else if target_triple.contains(\"windows\") {\n        libsui::PortableExecutable::from(host_bytes)\n            .context(\"failed to parse PE binary\")?\n            .write_resource(PACK_SECTION_NAME, data.to_vec())\n            .context(\"failed to write PE resource\")?\n            .build(writer)\n            .context(\"failed to build PE binary\")?;\n    } else if target_triple.contains(\"apple-darwin\") {\n        libsui::Macho::from(host_bytes.to_vec())\n            .context(\"failed to parse Mach-O binary\")?\n            .write_section(PACK_SECTION_NAME, data.to_vec())\n            .context(\"failed to write Mach-O section\")?\n            .build_and_sign(writer)\n            .context(\"failed to build Mach-O binary\")?;\n    } else {\n        anyhow::bail!(\"unsupported pack target `{target_triple}`\");\n    }\n    Ok(())\n}\n// Tests\n// ============================================================================\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    fn engine_from_source(source: &str) -> BexEngine {\n        let snapshot = baml_tests::engine::compile_source(source);\n        BexEngine::new(snapshot, Arc::new(sys_native::SysOps::native()), Vec::new())\n            .expect(\"BexEngine::new should succeed\")\n    }\n\n    /// Build an engine from a multi-file project so we can exercise\n    /// namespaced functions (`ns_<name>/foo.baml` → `<name>.foo`). Single","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/pack_command.rs#L657-L693","documentation":"`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.","triggerScenarios":"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}`\")`.","commonSituations":"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.","solutions":["Pack only for supported desktop targets (Linux ELF, Windows PE, macOS Mach-O).","Cross-check the triple's OS: pack for the target's actual OS rather than an emulator/virtual target like wasm32.","If the triple should be supported, request/await upstream support in the pack command's `write_executable` for that binary format.","As a workaround, distribute the packed binary per-platform instead of trying to pack one universal artifact."],"exampleFix":"// before\n$ baml pack wasm32-wasi myFn\n// after (pack for a supported platform)\n$ baml pack x86_64-unknown-linux-gnu myFn","handlingStrategy":"validation","validationCode":"const PACKABLE_TARGETS: &[&str] = &[\n    \"x86_64-unknown-linux-gnu\", \"aarch64-unknown-linux-gnu\",\n    \"aarch64-apple-darwin\", \"x86_64-apple-darwin\", \"x86_64-pc-windows-msvc\",\n];\nif !PACKABLE_TARGETS.contains(&target_triple) {\n    eprintln!(\"target {target_triple} has no section writer; pick one of {PACKABLE_TARGETS:?}\");\n    std::process::exit(2);\n}","typeGuard":"fn is_packable(triple: &str) -> bool {\n    matches!(triple, \"x86_64-unknown-linux-gnu\" | \"aarch64-apple-darwin\" | \"x86_64-pc-windows-msvc\" | _)\n        // in real code: explicit list of ELF/PE/Mach-O triples\n}","tryCatchPattern":"match write_executable(&writer, &data, target_triple) {\n    Ok(()) => (),\n    Err(e) if e.to_string().starts_with(\"unsupported pack target\") => {\n        eprintln!(\"{e}; pack only Linux/Windows/macOS desktop targets\");\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Only pack for the three supported executable formats: ELF (Linux), PE (Windows), Mach-O (macOS).","Never target wasm/emulated/bare-metal triples with the pack command.","Keep a per-platform release pipeline instead of trying to produce a universal packed binary.","If you need a new platform, check whether `write_executable` gained a writer for it before attempting."],"tags":["rust","cli","platform","unsupported"],"backgroundTag":"unsupported-platform","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}