{"record":{"id":"578c506eaccc8b06","repo":"BoundaryML/baml","slug":"symbol-symbol-not-found-in-baml-library-source","errorCode":null,"errorMessage":"Symbol '{symbol}' not found in BAML library: {source}","messagePattern":"Symbol '(.+?)' not found in BAML library: (.+?)","errorType":"exception","errorClass":"BamlSysError","httpStatus":null,"severity":"critical","filePath":"languages/rust/baml-sys/src/error.rs","lineNumber":22,"sourceCode":"\n/// Errors that can occur during library loading.\n#[derive(Debug, thiserror::Error)]\n#[allow(missing_docs)] // Error variants are self-documenting via #[error(...)]\npub enum BamlSysError {\n    /// Library file not found at any search path.\n    #[error(\"BAML library not found. Searched paths: {searched_paths:?}\")]\n    LibraryNotFound { searched_paths: Vec<PathBuf> },\n\n    /// Failed to load the dynamic library.\n    #[error(\"Failed to load BAML library from {path}: {source}\")]\n    LoadFailed {\n        path: PathBuf,\n        #[source]\n        source: libloading::Error,\n    },\n\n    /// Symbol not found in loaded library.\n    #[error(\"Symbol '{symbol}' not found in BAML library: {source}\")]\n    SymbolNotFound {\n        symbol: &'static str,\n        #[source]\n        source: libloading::Error,\n    },\n\n    /// Version mismatch between Rust package and loaded library.\n    #[error(\"Version mismatch: Rust package expects {expected}, but library reports {actual}\")]\n    VersionMismatch { expected: String, actual: String },\n\n    /// Platform not supported.\n    #[error(\"Platform not supported: {os}/{arch}\")]\n    UnsupportedPlatform {\n        os: &'static str,\n        arch: &'static str,\n    },\n\n    /// Failed to determine cache directory.","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/languages/rust/baml-sys/src/error.rs#L4-L40","documentation":"`BamlSysError::SymbolNotFound` from baml-sys: the library loaded, but a required exported symbol (`symbol`) was missing, with the `libloading::Error` as source. This indicates the loaded library's exported API does not match what the Rust binding expects.","triggerScenarios":"`lib.get(b\"symbol_name\")` failing because the loaded library is an older/newer build that doesn't export the expected FFI symbol.","commonSituations":"Rust bindings updated but native library stale (or vice versa); symbol renamed in a refactor; loading the wrong library file that lacks the export.","solutions":["Rebuild the native BAML library from the matching source revision so it exports the expected symbol","Align versions of the Rust binding package and the native library (reinstall both together)","Verify the symbol exists with `nm -D` / `objdump -T` and correct the path to the intended library"],"exampleFix":"// before\nlet f: Symbol<...> = unsafe { lib.get(b\"baml_invoke_v1\")? }; // SymbolNotFound with stale lib\n// after\nlet f: Symbol<...> = unsafe { lib.get(b\"baml_invoke_v2\")? }; // matches rebuilt library","handlingStrategy":"validation","validationCode":"// verify required symbol before binding\nif std::process::Command::new(\"nm\").arg(\"-D\").arg(lib_path)\n    .output().map(|o| String::from_utf8_lossy(&o.stdout).contains(\"baml_invoke\")).unwrap_or(false) { /* ok */ }","typeGuard":null,"tryCatchPattern":"match load_baml_sys() {\n    Err(BamlSysError::SymbolNotFound { symbol, source }) => {\n        eprintln!(\"Native lib missing symbol {symbol}: {source}; rebuild native lib to match bindings\");\n    }\n    Ok(sys) => { /* use sys */ }\n}","preventionTips":["Version-check immediately after load before other calls","Always upgrade Rust bindings and native library together","Verify exports with nm/objdump after rebuilding","Pin native library artifacts per bindings version"],"tags":["rust","ffi","symbols","version-mismatch"],"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-23T08:17:48.524Z"}