BoundaryML/baml · error
failed to create engine: {e:?}
Error message
failed to create engine: {e:?} What it means
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.
Source
Thrown at baml_language/crates/baml_cli/src/run_command.rs:366
anyhow::bail!("{bail_context}");
}
/// Compile `db` to bytecode and build a `BexEngine`.
fn compile_to_engine(
&self,
db: &ProjectDatabase,
package: SourceRoot,
argv: Vec<String>,
) -> Result<BexEngine> {
let bytecode = baml_compiler2_emit::generate_project_bytecode(db, package)
.map_err(|e| anyhow!("compilation failed: {e:?}"))?;
BexEngine::new_with_runtime_compiler(
bytecode,
Arc::new(sys_native::SysOps::native()),
argv,
bex_project::runtime_compiler(),
)
.map_err(|e| anyhow!("failed to create engine: {e:?}"))
}
pub fn run(&self) -> Result<crate::ExitCode> {
let reporter = Reporter::new();
let outcome = self.run_with_reporter(&reporter);
emit_profiling_status();
outcome
}
}
/// A profiling failure never breaks the run, so by default it is invisible;
/// verbose is the window into why a store is absent — or where an active one
/// actually wrote. Must run on EVERY exit path, including the
/// `std::process::exit` branches for program-controlled exit codes.
fn emit_profiling_status() {
if crate::reporter::verbose() {
let status = bex_events::prof::backend::ProfilerSession::global().status_line();
crate::reporter::print_verbose(format_args!("profiling: {status}"));View on GitHub (pinned to bd85ce9dee)
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
Defensive patterns
Strategy: try-catch
Try / catch
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; } Prevention
- 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
When it happens
Trigger: `compile_to_engine` calls `BexEngine::new_with_runtime_compiler(...)` and it returns Err, from `load_and_compile_standalone` or `run_expression`.
Common situations: Runtime/runtime-compiler initialization failures; invalid argv passed to the engine; environment problems with the native runtime; internal invariant failures in bex_project.
Related errors
- failed to create engine: {e:?}
- compilation failed: {e:?}
- failed to initialize engine for resolution: {e:?}
- no `.baml` files found in {}
- could not find packaged playground assets. For local debuggi
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/dc361bf7de3e5513.
Report an issue: GitHub.