{"record":{"id":"1a478f436697b9b8","repo":"tonhowtf/omniget","slug":"n-o-achei-o-diret-rio-de-dados-do-app","errorCode":null,"errorMessage":"não achei o diretório de dados do app","messagePattern":"não achei o diretório de dados do app","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/onnxrt.rs","lineNumber":459,"sourceCode":"\n/// Baixa (conferindo o sha256), extrai e deixa a lib pronta para o `init()`.\npub async fn ensure_runtime(\n    variant: Option<String>,\n    progress: &crate::core::tools::ProgressFn,\n) -> anyhow::Result<PathBuf> {\n    if let Some(p) = resolve_path() {\n        return Ok(p);\n    }\n    install_runtime(variant, progress).await\n}\n\n/// Instala mesmo que já exista — é o \"atualizar\" da tela de Modelos.\npub async fn install_runtime(\n    variant: Option<String>,\n    progress: &crate::core::tools::ProgressFn,\n) -> anyhow::Result<PathBuf> {\n    let asset = pick_asset(variant.as_deref())?;\n    let dir = target_dir().ok_or_else(|| anyhow!(\"não achei o diretório de dados do app\"))?;\n    std::fs::create_dir_all(&dir).with_context(|| format!(\"criando {}\", dir.display()))?;\n\n    let url = format!(\"{}/v{}/{}\", RELEASE_BASE, RUNTIME_VERSION, asset.file);\n    let tmp = crate::core::tools::temp_dir().join(asset.file);\n    let client = crate::core::tools::client()?;\n    crate::core::tools::download_to(&client, &url, &tmp, progress, \"onnxruntime\").await?;\n\n    let asset_file = asset.file.to_string();\n    let expected = asset.sha256.to_string();\n    let is_zip = asset_file.ends_with(\".zip\");\n    let dir_for_task = dir.clone();\n    let tmp_for_task = tmp.clone();\n    let p = progress.clone();\n    let out = tokio::task::spawn_blocking(move || -> anyhow::Result<PathBuf> {\n        crate::core::tools::report(\n            &p,\n            \"onnxruntime\",\n            \"verify\",","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/onnxrt.rs#L441-L477","documentation":"Raised by install_runtime() when target_dir() returns None, i.e. the app cannot determine its per-user data directory to install the runtime into. The download pipeline cannot proceed without a destination.","triggerScenarios":"install_runtime() or install_from_path() called in an environment where the OS data-dir lookup fails: no XDG_DATA_HOME/HOME, non-standard Tauri context, sandboxed/headless environment.","commonSituations":"Running the Tauri app as a service with unset HOME; CI containers without user dirs; corrupted XDG configuration; running with restricted environment variables.","solutions":["Set HOME (and XDG_DATA_HOME on Linux) to a writable directory before launching the app","Run the app as a normal logged-in user session, not as a system service","Ensure the OS app-data API (Tauri path resolver) works — check app configuration/permissions","Create the expected data directory manually and re-run"],"exampleFix":"// before\ncargo test ... # in CI container: \"não achei o diretório de dados do app\"\n// after\nenv:\n  HOME: /home/runner\n  XDG_DATA_HOME: /home/runner/.local/share","handlingStrategy":"validation","validationCode":"if std::env::var_os(\"HOME\").is_none() { eprintln!(\"HOME must be set\"); std::process::exit(1); }","typeGuard":"fn data_dir_ready() -> bool { std::env::var_os(\"HOME\").map(|h| std::path::PathBuf::from(h).is_dir()).unwrap_or(false) }","tryCatchPattern":"match onnxrt::install_runtime(None, &progress).await { Err(e) if e.to_string().contains(\"diretório de dados\") => fix_env_and_retry(), ... }","preventionTips":["Always launch the app with HOME set (services, CI)","Set XDG_DATA_HOME explicitly in containers","Create the app data dir during first-run setup"],"tags":["rust","tauri","filesystem","configuration"],"backgroundTag":"directory-not-found","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"}