{"record":{"id":"973ee9b0474badcf","repo":"cjpais/Handy","slug":"failed-to-load-moonshine-model","errorCode":null,"errorMessage":"Failed to load moonshine model {}: {}","messagePattern":"Failed to load moonshine model (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/transcription.rs","lineNumber":658,"sourceCode":"                let engine =\n                    ParakeetModel::load(&model_path, &Quantization::Int8).map_err(|e| {\n                        let error_msg =\n                            format!(\"Failed to load parakeet model {}: {}\", model_id, e);\n                        emit_loading_failed(&error_msg);\n                        anyhow::anyhow!(error_msg)\n                    })?;\n                LoadedEngine::Parakeet(engine)\n            }\n            EngineType::Moonshine => {\n                let engine = MoonshineModel::load(\n                    &model_path,\n                    MoonshineVariant::Base,\n                    &Quantization::default(),\n                )\n                .map_err(|e| {\n                    let error_msg = format!(\"Failed to load moonshine model {}: {}\", model_id, e);\n                    emit_loading_failed(&error_msg);\n                    anyhow::anyhow!(error_msg)\n                })?;\n                LoadedEngine::Moonshine(engine)\n            }\n            EngineType::MoonshineStreaming => {\n                let engine = StreamingModel::load(&model_path, 0, &Quantization::default())\n                    .map_err(|e| {\n                        let error_msg = format!(\n                            \"Failed to load moonshine streaming model {}: {}\",\n                            model_id, e\n                        );\n                        emit_loading_failed(&error_msg);\n                        anyhow::anyhow!(error_msg)\n                    })?;\n                LoadedEngine::MoonshineStreaming(engine)\n            }\n            EngineType::SenseVoice => {\n                let engine =\n                    SenseVoiceModel::load(&model_path, &Quantization::Int8).map_err(|e| {","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/cjpais/Handy/blob/ba10ce1943ef34e93c09494027fc0b9ced2e8a44/src-tauri/src/managers/transcription.rs#L640-L676","documentation":"Thrown when MoonshineModel::load from transcribe-rs fails to instantiate the Moonshine Base ONNX model from the files at model_path. The underlying ONNX Runtime error is appended after the model_id. Before returning, the code emits a `model-state-changed` event with event_type \"loading_failed\" so the frontend can show the failure.","triggerScenarios":"TranscriptionManager::load_model runs with EngineType::Moonshine and MoonshineModel::load(&model_path, MoonshineVariant::Base, &Quantization::default()) errors: model directory missing, .onnx file truncated/partially downloaded, wrong file layout for the expected variant, or ONNX Runtime cannot create a session (missing/incompatible execution provider libraries).","commonSituations":"Interrupted or disk-full model download leaving a short file; user or cleaner deleted the app-data models directory; app upgrade changed the expected model file layout; onnxruntime dynamic library missing or version-mismatched after an update; antivirus quarantining the .onnx file.","solutions":["Delete and re-download the model from the model selector (most load failures are corrupt/incomplete downloads)","Verify the model directory exists and file sizes match what ModelManager recorded for the model","Check free disk space and filesystem permissions on the app-data models path","Read the chained ONNX Runtime error after the colon in the log line to identify provider/session issues","If the error mentions the execution provider, switch the ONNX accelerator setting to CPU and retry, or try a different engine's model"],"exampleFix":"// before: load directly, fail on corrupt download\nlet engine = MoonshineModel::load(&model_path, MoonshineVariant::Base, &Quantization::default())?;\n\n// after: verify the download is complete before loading\nif !model_path.exists() || std::fs::read_dir(&model_path)?.next().is_none() {\n    model_manager.delete_model(&model_id)?;\n    model_manager.download_model(&model_id).await?;\n}\nlet engine = MoonshineModel::load(&model_path, MoonshineVariant::Base, &Quantization::default())?;","handlingStrategy":"try-catch","validationCode":"// before load_model: confirm the model files are present and non-empty\nuse std::fs;\nfn model_files_intact(model_path: &std::path::Path) -> bool {\n    match fs::read_dir(model_path) {\n        Ok(mut entries) => entries.next().map_or(false, |e| {\n            e.and_then(|e| fs::metadata(e.path()).map(|m| m.len() > 0)).unwrap_or(false)\n        }),\n        Err(_) => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"match manager.load_model(&model_id, None) {\n    Ok(()) => { /* proceed; frontend already got load-completed event */ }\n    Err(e) => {\n        // a `loading_failed` model-state event was already emitted with the same text\n        log::error!(\"model load failed: {e:#}\");\n        model_manager.delete_model(&model_id).ok();\n        // schedule re-download, then retry load_model once\n    }\n}","preventionTips":["Never kill the app mid-download; let ModelManager finish writing model files","Do not manually delete or move files under the app-data models directory","Subscribe to model-state-changed events and block recording UI while a load is failing","Keep the onnxruntime runtime libraries bundled with the app; do not swap system copies"],"tags":["rust","onnx","moonshine","model-loading","transcribe-rs"],"backgroundTag":"onnx-model-load-failed","analyzedSha":"ba10ce1943ef34e93c09494027fc0b9ced2e8a44","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}