{"record":{"id":"34285fcb8f0e5eeb","repo":"tonhowtf/omniget","slug":"could-not-determine-data-directory","errorCode":null,"errorMessage":"Could not determine data directory","messagePattern":"Could not determine data directory","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/dependencies.rs","lineNumber":400,"sourceCode":"                crate::core::ytdlp::reset_ffmpeg_location_cache();\n                return Ok(path);\n            }\n        }\n    }\n\n    if let Some(path) = find_tool(\"ffmpeg\").await {\n        return Ok(path);\n    }\n    if is_flatpak() {\n        return Err(anyhow!(\"FFmpeg not found in Flatpak sandbox\"));\n    }\n    let path = download_ffmpeg().await?;\n    crate::core::ytdlp::reset_ffmpeg_location_cache();\n    Ok(path)\n}\n\nasync fn download_ffmpeg() -> anyhow::Result<PathBuf> {\n    let bin_dir = managed_bin_dir().ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;\n    std::fs::create_dir_all(&bin_dir)?;\n\n    let ffmpeg_name = bin_name(\"ffmpeg\");\n    let ffprobe_name = bin_name(\"ffprobe\");\n    let ffmpeg_target = bin_dir.join(&ffmpeg_name);\n\n    let downloads = ffmpeg_download_urls();\n\n    let client = crate::core::http_client::apply_global_proxy(reqwest::Client::builder())\n        .timeout(std::time::Duration::from_secs(300))\n        .build()?;\n\n    for (url, archive_type) in downloads {\n        tracing::info!(\"Downloading FFmpeg component from {}\", url);\n        let response = client.get(url).send().await?;\n        if !response.status().is_success() {\n            return Err(anyhow!(\n                \"Failed to download FFmpeg from {}: HTTP {}\",","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/dependencies.rs#L382-L418","documentation":"download_ffmpeg() resolves the directory where FFmpeg binaries are installed via managed_bin_dir(). When that helper returns None — typically because the app data directory cannot be resolved (no home directory, missing XDG/app-data environment, or unsupported platform layout) — the code converts it to this anyhow error with the ? operator and aborts the download.","triggerScenarios":"Calling ensure_ffmpeg() or update_ffmpeg() on a system where managed_bin_dir() yields None: HOME unset, no writable app-data directory, or an embedded/nonstandard runtime where the data-dir lookup fails.","commonSituations":"Running the app as a system service with no HOME set; sandboxed/CI environments without a user profile; unusual platform builds where the Tauri app-data path is unavailable.","solutions":["Ensure the process runs with a valid HOME/user profile (or set XDG_DATA_HOME) before invoking ensure_ffmpeg/update_ffmpeg","Check managed_bin_dir() to see which lookup fails and fix the environment or hardcode a fallback directory","Run the app as a normal user rather than as root/service without a home directory","Verify the target platform is supported by the data-dir resolution logic"],"exampleFix":"// before\nlet bin_dir = managed_bin_dir().ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;\n// after\nlet bin_dir = managed_bin_dir().unwrap_or_else(|| {\n    dirs::data_dir().unwrap_or_else(|| std::env::temp_dir().join(\"omniget\"))\n});","handlingStrategy":"validation","validationCode":"if managed_bin_dir().is_none() {\n    eprintln!(\"No data directory available; set HOME or XDG_DATA_HOME before installing FFmpeg\");\n    return;\n}","typeGuard":"fn has_data_dir() -> bool { managed_bin_dir().is_some() }","tryCatchPattern":"match download_ffmpeg().await {\n    Ok(path) => println!(\"installed at {}\", path.display()),\n    Err(e) if e.to_string().contains(\"data directory\") => configure_data_dir_and_retry(),\n    Err(e) => eprintln!(\"ffmpeg install failed: {e}\"),\n}","preventionTips":["Never run the app as a service without a home directory; set HOME/XDG equivalents explicitly","Add a fallback data-dir (temp dir) inside managed_bin_dir","Log the failing lookup inside managed_bin_dir so the cause is visible","Check data-dir availability at app startup, before first install"],"tags":["rust","anyhow","filesystem","configuration"],"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"}