BoundaryML/baml · critical · BamlSysError
BAML library not found. Searched paths
Error message
BAML library not found. Searched paths: {searched_paths:?} What it means
`BamlSysError::LibraryNotFound` from baml-sys, reported via thiserror. The native BAML dynamic library (`.so`/`.dylib`/`.dll`) could not be located at any of the configured search paths at load time. The message lists every path that was searched so you can see what was tried.
Solutions
- Build or install the native BAML library and place it in one of the listed search paths
- Fix the library search path configuration / env (e.g. point loader at the actual .so/.dylib/.dll location)
- Install the correct platform-specific package variant matching your OS/arch
Example fix
// before let sys = BamlSys::new(&["/opt/nonexistent/lib"])?; // LibraryNotFound // after let sys = BamlSys::new(&["/opt/nonexistent/lib", "/usr/local/lib"])?; // ensure libbaml.so exists: cp target/release/libbaml.so /usr/local/lib/
Defensive patterns
Strategy: validation
Validate before calling
let paths = candidate_paths();
let missing: Vec<_> = paths.iter().filter(|p| !p.exists()).collect();
if missing.len() == paths.len() { return Err("BAML native library not installed"); } Type guard
fn library_present(path: &std::path::Path) -> bool { path.is_file() } Try / catch
match load_baml_sys() {
Err(BamlSysError::LibraryNotFound { searched_paths }) => {
eprintln!("Build/install the native lib; searched: {searched_paths:?}");
}
Ok(sys) => { /* use sys */ }
} Prevention
- Build the native library as part of your build/install script
- Verify library presence at startup with a fail-fast check
- Keep search paths configurable via env/config
- Install the platform-matching package variant in CI images
When it happens
Trigger: Initializing/loading the BAML library through baml-sys before the native library has been built or installed, or when search paths point to the wrong directories.
Common situations: Fresh clone without building the native lib; library installed to a nonstandard location not on the search path; wrong package variant for your platform; CI images missing the native artifact.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Failed to load BAML library from
- {0}
- Engine not initialized. Call create_baml_runtime first.
- Expected Collector, got
- Expected string value for tag key
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/9aa4a670a0b3a2f1.
Report an issue: GitHub.
Appendix: source
Thrown at languages/rust/baml-sys/src/error.rs:10
//! Error types for baml-sys library loading.
use std::path::PathBuf;
/// Errors that can occur during library loading.
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)] // Error variants are self-documenting via #[error(...)]
pub enum BamlSysError {
/// Library file not found at any search path.
#[error("BAML library not found. Searched paths: {searched_paths:?}")]
LibraryNotFound { searched_paths: Vec<PathBuf> },
/// Failed to load the dynamic library.
#[error("Failed to load BAML library from {path}: {source}")]
LoadFailed {
path: PathBuf,
#[source]
source: libloading::Error,
},
/// Symbol not found in loaded library.
#[error("Symbol '{symbol}' not found in BAML library: {source}")]
SymbolNotFound {
symbol: &'static str,
#[source]
source: libloading::Error,
},
View on GitHub (pinned to bd85ce9dee)