{"record":{"id":"f407d51e7a70a827","repo":"BoundaryML/baml","slug":"package-initialization-failed-0","errorCode":null,"errorMessage":"Package initialization failed: {0}","messagePattern":"Package initialization failed: (.+?)","errorType":"exception","errorClass":"EngineError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_engine/src/lib.rs","lineNumber":858,"sourceCode":"    Exit { code: i64 },\n\n    #[error(\"Cannot convert object of type {type_name}\")]\n    CannotConvert { type_name: String },\n\n    #[error(\"Type mismatch: {message}\")]\n    TypeMismatch { message: String },\n\n    #[error(\"Schema inconsistency: {message}\")]\n    SchemaInconsistency { message: String },\n\n    #[cfg(feature = \"heap_debug\")]\n    #[error(\"Snapshot not possible for type: {type_name}\")]\n    CannotSnapshot { type_name: String },\n\n    #[error(\"A function call with ID {call_id} is already in progress\")]\n    DuplicateCallId { call_id: CallId },\n\n    #[error(\"Package initialization failed: {0}\")]\n    InitFailed(String),\n\n    #[error(\"{0}\")]\n    Other(String),\n}\n\nfn format_vm_internal_error(\n    err: &bex_vm::errors::VmInternalError,\n    trace: &[bex_vm::StackFrame],\n) -> String {\n    use std::fmt::Write;\n    let mut out = bex_vm::format_traceback(\n        trace\n            .iter()\n            .map(|f| (f.file_path.as_str(), f.error_line, f.function_name.as_str())),\n    );\n    write!(out, \"VM internal error: {err}\").unwrap();\n    out","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_engine/src/lib.rs#L840-L876","documentation":"Initialization of a BAML package (loading, linking, and preparing its compiled artifacts for execution) failed, with the underlying reason carried as a string. Thrown when the engine cannot bring a package into a runnable state.","triggerScenarios":"Loading a BAML package via the engine's package-init API when artifacts are missing/corrupt, dependencies fail to resolve, or the package references functions/types that cannot be linked.","commonSituations":"Deployments shipping incomplete build outputs; corrupted caches; version-skewed generated packages; missing runtime dependencies for the package.","solutions":["Read the inner message for the specific cause","Rebuild the package from clean state (clear caches, regenerate artifacts)","Verify the package was built with a compiler version compatible with the engine","Ensure all package dependencies/files are present in the deployment"],"exampleFix":"// before: shipping partial package\nupload(pkg_dir) // missing some generated files\n// after: full clean build\nbaml clean && baml build && upload(pkg_dir)","handlingStrategy":"try-catch","validationCode":"// pre-flight: artifacts present and version-compatible\nassert!(pkg.artifacts_complete());\nassert!(pkg.compiler_version().is_compatible_with(ENGINE_VERSION));","typeGuard":null,"tryCatchPattern":"match result {\n    Err(EngineError::InitFailed(msg)) => {\n        eprintln!(\"package init failed: {msg}; rebuilding...\");\n        rebuild_and_retry()?;\n    }\n    Ok(v) => use(v),\n    Err(e) => handle(e),\n}","preventionTips":["Build packages with a clean full build before deployment","Ship complete artifact sets in CI","Verify compiler/engine version compatibility at startup"],"tags":["initialization","package","baml"],"backgroundTag":"module-init-failed","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"}