{"record":{"id":"667ca71fe4d07c0f","repo":"aaif-goose/goose","slug":"failed-to-init-llama-backend","errorCode":null,"errorMessage":"Failed to init llama backend: {}","messagePattern":"Failed to init llama backend: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/goose-local-inference/src/llamacpp/mod.rs","lineNumber":361,"sourceCode":"pub(super) struct LlamaCppBackend {\n    backend: LlamaBackend,\n}\n\nimpl LlamaCppBackend {\n    pub(super) fn new() -> Result<Self> {\n        check_cpu_supports_local_inference()?;\n\n        let backend = match LlamaBackend::init() {\n            Ok(backend) => backend,\n            Err(llama_cpp_2::LlamaCppError::BackendAlreadyInitialized) => {\n                unreachable!(\n                    \"LlamaBackend already initialized but Weak was dead; \\\n                     the runtime mutex prevents concurrent re-init\"\n                )\n            }\n            Err(e) => {\n                tracing::error!(error = %e, \"failed to initialize local inference runtime\");\n                return Err(anyhow::anyhow!(\"Failed to init llama backend: {}\", e));\n            }\n        };\n\n        llama_cpp_2::send_logs_to_tracing(LogOptions::default());\n        log_inference_backend_devices();\n\n        Ok(Self { backend })\n    }\n\n    pub(super) fn llama_backend(&self) -> &LlamaBackend {\n        &self.backend\n    }\n\n    fn init_mtmd_context(\n        model: &LlamaModel,\n        mmproj_path: &Option<PathBuf>,\n        settings: &crate::local_model_registry::ModelSettings,\n    ) -> Option<llama_cpp_2::mtmd::MtmdContext> {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-local-inference/src/llamacpp/mod.rs#L343-L379","documentation":"llama_cpp_2's LlamaBackend::init() failed with an error other than BackendAlreadyInitialized (which the surrounding runtime mutex makes unreachable here). In practice this means the llama.cpp backend library itself failed to initialize/load - missing or corrupt shared library, ABI/glibc mismatch, loader error - and the underlying LlamaCppError is appended. Local llama.cpp inference cannot start when this fires.","triggerScenarios":"LlamaCppBackend::new() at first local-model use: corrupted install artifacts, an incompatible system loader forcing the wrong libllama, or LD_LIBRARY_PATH/DYLD_* injection breaking the bundled library load.","commonSituations":"Interrupted updates leaving a half-written library; mismatched glibc on older Linux distros; environment variables pointing at a different llama.cpp build; antivirus quarantining the .so/.dylib.","solutions":["Reinstall goose to restore the bundled llama.cpp library","Clear LD_LIBRARY_PATH / DYLD_INSERT_LIBRARIES interference and retry","Read the appended LlamaCppError text: loader messages name the exact file or symbol that failed","Fall back to a non-local provider while gathering the full error for a bug report"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match LlamaCppBackend::new() {\n    Err(e) if e.to_string().starts_with(\"Failed to init llama backend\") => {\n        // capture the appended LlamaCppError, prompt a reinstall,\n        // and switch the session to a non-local provider in the meantime\n    }\n    other => other,\n}","preventionTips":["Verify the install (checksums or a fresh download) after updates","Keep LD_LIBRARY_PATH/DYLD_* clean so the bundled libllama loads","Log the full LlamaCppError text; loader errors name the missing artifact"],"tags":["rust","llamacpp","native-library","initialization","local-inference"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}