{"record":{"id":"cb7d04d3ebac7001","repo":"tonhowtf/omniget","slug":"could-not-determine-data-directory-whisper","errorCode":null,"errorMessage":"Could not determine data directory","messagePattern":"Could not determine data directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src-tauri/omniget-core/src/core/tools/whisper.rs","lineNumber":89,"sourceCode":"                    .replace(\"q5_0\", \"(q5)\")\n                    .replace(\"q5_1\", \"(q5)\"),\n                size_mb: *mb,\n                note: note.to_string(),\n                installed: size > 0,\n                path: path\n                    .filter(|_| size > 0)\n                    .map(|p| p.to_string_lossy().to_string()),\n                size_bytes: size,\n            }\n        })\n        .collect()\n}\n\npub async fn download_model(id: &str, progress: ProgressFn) -> anyhow::Result<PathBuf> {\n    if !MODELS.iter().any(|(m, _, _)| *m == id) {\n        return Err(anyhow!(\"modelo desconhecido: {}\", id));\n    }\n    let dir = models_dir().ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;\n    std::fs::create_dir_all(&dir)?;\n    let dest = dir.join(format!(\"ggml-{}.bin\", id));\n    let url = format!(\"{}/ggml-{}.bin\", HF_BASE, id);\n    let client = super::client()?;\n    super::download_to(\n        &client,\n        &url,\n        &dest,\n        &progress,\n        &format!(\"whisper-model:{}\", id),\n    )\n    .await?;\n    Ok(dest)\n}\n\npub fn remove_model(id: &str) -> anyhow::Result<()> {\n    let dir = models_dir().ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;\n    let p = dir.join(format!(\"ggml-{}.bin\", id));","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/whisper.rs#L71-L107","documentation":"download_model calls models_dir(), which returns Option<PathBuf>; when it yields None (the app data directory cannot be determined) the model download aborts with 'Could not determine data directory'. This typically means the OS-specific base-directory lookup failed.","triggerScenarios":"models_dir() returns None because the required XDG/HOME environment variables are unset (headless Linux/service contexts) or the platform's data-dir API fails during a model download.","commonSituations":"Running the app as a systemd service or cron job with no HOME set, containerized environments without XDG_DATA_HOME, or unusual Windows profile configurations.","solutions":["Ensure HOME (Linux/macOS) or USERPROFILE (Windows) is set for the process running the app.","Set XDG_DATA_HOME (Linux) or an equivalent env var so the data directory can be resolved.","Allow overriding the models directory via configuration so users can pass an explicit path.","Inspect models_dir()'s implementation to see which directory API returns None on your platform."],"exampleFix":"// before (shell)\ncargo tauri dev   # fails under service: no HOME\n// after (shell)\nexport HOME=/home/appuser\nexport XDG_DATA_HOME=/var/lib/appuser/.local/share\ncargo tauri dev","handlingStrategy":"fallback","validationCode":"// Pre-check before starting downloads\nif std::env::var(\"HOME\").is_err() && std::env::var(\"XDG_DATA_HOME\").is_err() {\n    return Err(\"set HOME or XDG_DATA_HOME so the models directory can be resolved\".into());\n}","typeGuard":null,"tryCatchPattern":"match download_model(id, progress).await {\n    Err(e) if e.to_string().contains(\"Could not determine data directory\") => {\n        // fall back: set a temp dir override or prompt the user for a models folder\n        eprintln!(\"data directory unresolved; configure an explicit models directory\");\n    }\n    other => other?,\n}","preventionTips":["Ensure HOME/USERPROFILE is set when running under services, cron, or containers.","Set XDG_DATA_HOME explicitly in deployment environments.","Provide a config option to override the models directory path.","Probe the data directory at app startup and fail fast with a clear message."],"tags":["environment","config","paths","rust"],"backgroundTag":"missing-env-var","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}