{"record":{"id":"0a8fb545b8cd4b47","repo":"cjpais/Handy","slug":"failed-to-resolve-vad-path","errorCode":null,"errorMessage":"Failed to resolve VAD path: {}","messagePattern":"Failed to resolve VAD path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/audio.rs","lineNumber":541,"sourceCode":"            mute_guard.did_mute = false;\n            debug!(\n                \"Mute removed (restored prev_muted={:?})\",\n                mute_guard.prev_muted\n            );\n        }\n    }\n\n    pub fn preload_vad(&self) -> Result<(), anyhow::Error> {\n        let mut recorder_opt = self.recorder.lock().unwrap();\n        if recorder_opt.is_none() {\n            let vad_path = self\n                .app_handle\n                .path()\n                .resolve(\n                    \"resources/models/silero_vad_v4.onnx\",\n                    tauri::path::BaseDirectory::Resource,\n                )\n                .map_err(|e| anyhow::anyhow!(\"Failed to resolve VAD path: {}\", e))?;\n            let settings = get_settings(&self.app_handle);\n            *recorder_opt = Some(create_audio_recorder(\n                &vad_path,\n                &self.app_handle,\n                settings.selected_channel,\n                Arc::clone(&self.stream_router),\n            )?);\n        }\n        Ok(())\n    }\n\n    pub fn start_microphone_stream(&self) -> Result<(), anyhow::Error> {\n        let mut open_flag = self.is_open.lock().unwrap();\n        if *open_flag {\n            // `is_open` only records that we opened a stream at some point, not\n            // that one is still running. If the capture worker has since exited\n            // (mic unplugged mid-session, USB dropout), returning Ok here hands\n            // the caller a dead recorder: it captures nothing, then fails in","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/cjpais/Handy/blob/98a4d80cce8ad41efec2a419b59d9e81229a35d7/src-tauri/src/managers/audio.rs#L523-L559","documentation":"Tauri's path().resolve(\"resources/models/silero_vad_v4.onnx\", BaseDirectory::Resource) failed while preload_vad lazily built the recorder. resolve() errors when the Resource base directory itself cannot be determined for the platform, not merely when the file is absent (joining a missing file still succeeds).","triggerScenarios":"Running the raw target/debug binary directly instead of `bun run tauri dev` or an installed bundle, so the platform resource dir is not where the binary expects; a bundle identifier/context misconfiguration; executable moved out of its .app bundle (macOS) or install prefix (Linux).","commonSituations":"Developers launching the binary from target/ for quick tests; CI or distro packaging that relocates the executable without its resources; flatpak/snap confinement hiding the real resource path.","solutions":["Run through the supported entry points: `bun run tauri dev` or the built/installed app bundle","Verify resources/models/** is listed under bundle resources in tauri.conf.json","Confirm silero_vad_v4.onnx exists in the packaged resources directory next to the binary","If packaging relocates the binary, keep the resources directory layout intact"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// fail fast at startup instead of at first recording\nlet resource_dir = app_handle\n    .path()\n    .resource_dir()\n    .map_err(|e| anyhow::anyhow!(\"resource dir unavailable (run via `tauri dev` or the installed bundle): {e}\"))?;\nlet vad_file = resource_dir.join(\"resources/models/silero_vad_v4.onnx\");\nif !vad_file.is_file() {\n    anyhow::bail!(\"missing VAD model: {vad_file:?}\");\n}","typeGuard":null,"tryCatchPattern":"match app_handle.path().resolve(rel, tauri::path::BaseDirectory::Resource) {\n    Ok(p) => p,\n    Err(e) => anyhow::bail!(\"cannot resolve resource {rel}: {e} — are you running the raw binary?\"),\n}","preventionTips":["Always launch through `bun run tauri dev` or the installed app, never the bare target/ binary","Keep resources/models/** declared in bundle resources so packaged builds carry the file","Add a startup check that resource_dir() resolves before any lazy path work"],"tags":["rust","tauri","resource-path","packaging"],"backgroundTag":"resource-path-resolution-failed","analyzedSha":"98a4d80cce8ad41efec2a419b59d9e81229a35d7","analyzedAt":"2026-08-16T20:58:09.966Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}