{"record":{"id":"dc361bf7de3e5513","repo":"BoundaryML/baml","slug":"failed-to-create-engine-e","errorCode":null,"errorMessage":"failed to create engine: {e:?}","messagePattern":"failed to create engine: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":366,"sourceCode":"        anyhow::bail!(\"{bail_context}\");\n    }\n\n    /// Compile `db` to bytecode and build a `BexEngine`.\n    fn compile_to_engine(\n        &self,\n        db: &ProjectDatabase,\n        package: SourceRoot,\n        argv: Vec<String>,\n    ) -> Result<BexEngine> {\n        let bytecode = baml_compiler2_emit::generate_project_bytecode(db, package)\n            .map_err(|e| anyhow!(\"compilation failed: {e:?}\"))?;\n        BexEngine::new_with_runtime_compiler(\n            bytecode,\n            Arc::new(sys_native::SysOps::native()),\n            argv,\n            bex_project::runtime_compiler(),\n        )\n        .map_err(|e| anyhow!(\"failed to create engine: {e:?}\"))\n    }\n\n    pub fn run(&self) -> Result<crate::ExitCode> {\n        let reporter = Reporter::new();\n        let outcome = self.run_with_reporter(&reporter);\n        emit_profiling_status();\n        outcome\n    }\n}\n\n/// A profiling failure never breaks the run, so by default it is invisible;\n/// verbose is the window into why a store is absent — or where an active one\n/// actually wrote. Must run on EVERY exit path, including the\n/// `std::process::exit` branches for program-controlled exit codes.\nfn emit_profiling_status() {\n    if crate::reporter::verbose() {\n        let status = bex_events::prof::backend::ProfilerSession::global().status_line();\n        crate::reporter::print_verbose(format_args!(\"profiling: {status}\"));","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L348-L384","documentation":"Bytecode was generated successfully but constructing the `BexEngine` via `new_with_runtime_compiler` failed. The engine initialization (runtime wiring, native SysOps, argv) produced an error which is wrapped and surfaced.","triggerScenarios":"`compile_to_engine` calls `BexEngine::new_with_runtime_compiler(...)` and it returns Err, from `load_and_compile_standalone` or `run_expression`.","commonSituations":"Runtime/runtime-compiler initialization failures; invalid argv passed to the engine; environment problems with the native runtime; internal invariant failures in bex_project.","solutions":["Inspect the debug-formatted cause `{e:?}` for the engine initialization error","Check that argv passed to the engine is well-formed","Update the BAML CLI to the latest version","File an issue with the full debug output if it persists"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const engine = await runner.compileToEngine(db, pkg, argv); } catch (e) { if (String(e).startsWith('failed to create engine:')) { console.error(e.message); process.exit(1); } throw e; }","preventionTips":["Pass well-formed argv to the engine","Keep the native runtime dependencies installed and up to date","Upgrade the CLI when engine-init errors appear after a compiler update"],"tags":["cli","runtime","engine-init","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"}