{"record":{"id":"49d2cb2701be60f0","repo":"tonhowtf/omniget","slug":"could-not-determine-data-directory-upscale","errorCode":null,"errorMessage":"Could not determine data directory","messagePattern":"Could not determine data directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/upscale.rs","lineNumber":81,"sourceCode":"            path: None,\n            models: vec![],\n        },\n    }\n}\n\nfn asset_pick(name: &str) -> bool {\n    let os = if cfg!(target_os = \"windows\") {\n        \"windows\"\n    } else if cfg!(target_os = \"macos\") {\n        \"macos\"\n    } else {\n        \"ubuntu\"\n    };\n    name.starts_with(\"realesrgan-ncnn-vulkan\") && name.contains(os) && name.ends_with(\".zip\")\n}\n\npub async fn install(progress: super::ProgressFn) -> anyhow::Result<String> {\n    let dir = managed_dir().ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;\n    let client = github::client()?;\n    let asset = github::asset(&client, REPO, None, asset_pick).await?;\n    // Release de 2022: a API não tem digest para esses assets.\n    let data = github::download(&client, &asset, true, &progress, BIN).await?;\n    let staging = dir.with_extension(\"new\");\n    let _ = std::fs::remove_dir_all(&staging);\n    let (s2, n2) = (staging.clone(), asset.name.clone());\n    tokio::task::spawn_blocking(move || github::unpack(&data, &n2, &s2))\n        .await\n        .map_err(|e| anyhow!(\"Spawn blocking failed: {}\", e))??;\n    let Some(exe) = github::find_file(&staging, &bin_name(BIN)) else {\n        let _ = std::fs::remove_dir_all(&staging);\n        return Err(anyhow!(\"o pacote nao contem o {}\", BIN));\n    };\n    github::make_executable(&exe);\n    github::swap_dir(&staging, &dir)?;\n    github::strip_quarantine(&dir).await;\n    locate()","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/upscale.rs#L63-L99","documentation":"upscale::install() first resolves the managed tools directory via managed_dir(). If that returns None — meaning the application could not locate or create its per-user data directory — install aborts with this error before contacting GitHub. It indicates the environment lacks a resolvable data directory (e.g. no HOME/XDG_DATA_HOME/APPDATA).","triggerScenarios":"Calling install() on a system where managed_dir() returns None: HOME unset, XDG_DATA_HOME pointing nowhere writable, no APPDATA on Windows, or the data root could not be determined at all.","commonSituations":"Running inside a container or systemd service without HOME set; portable deployments with stripped environment; nonstandard OS layouts; CI sandboxes.","solutions":["Set the appropriate environment variable (HOME on Linux/macOS, APPDATA on Windows) before launching the app","Run the app as a normal desktop user rather than a service account without a home directory","Check managed_dir()'s implementation to see which directories it probes and create the expected directory manually","Pass an explicit data directory through configuration if the code supports overriding it"],"exampleFix":"// before\nHOME= ./myapp\n// after\nexport HOME=/home/user && ./myapp","handlingStrategy":"fallback","validationCode":"fn has_data_dir() -> bool {\n    std::env::var_os(\"HOME\").is_some()\n        || std::env::var_os(\"APPDATA\").is_some()\n        || std::env::var_os(\"XDG_DATA_HOME\").is_some()\n}","typeGuard":null,"tryCatchPattern":"match upscale::install(&progress).await {\n    Err(e) if e.to_string().contains(\"data directory\") => {\n        eprintln!(\"Configure HOME ou APPDATA e reinicie.\");\n    }\n    other => other,\n}","preventionTips":["Launch the app with HOME/APPDATA set (avoid bare service contexts)","Prefer normal desktop sessions over stripped systemd/container environments","Probe managed_dir() at startup and fail fast with a user-friendly message"],"tags":["filesystem","environment","data-directory","installation","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"}