{"record":{"id":"76e6339c66ca2773","repo":"tonhowtf/omniget","slug":"external-data-cache-os-cache-dir-unavailable-on-this","errorCode":null,"errorMessage":"external_data_cache: OS cache dir unavailable on this platform","messagePattern":"external_data_cache: OS cache dir unavailable on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/plugin_host.rs","lineNumber":136,"sourceCode":"            anyhow::bail!(\"external_data_cache: namespace must not be empty\");\n        }\n        if plugin_id.contains(['/', '\\\\', ':', '\\0']) || namespace.contains(['/', '\\\\', ':', '\\0'])\n        {\n            anyhow::bail!(\n                \"external_data_cache: plugin_id/namespace must not contain path separators or null bytes\"\n            );\n        }\n\n        // portable installs keep every file next to the app, so the cache\n        // lives under the app data dir instead of the OS cache dir\n        let base = if std::env::var(\"OMNIGET_PORTABLE\").is_ok() {\n            omniget_core::core::paths::app_data_dir()\n                .ok_or_else(|| anyhow::anyhow!(\"external_data_cache: app data dir unavailable\"))?\n                .join(\"cache\")\n        } else {\n            dirs::cache_dir()\n                .ok_or_else(|| {\n                    anyhow::anyhow!(\n                        \"external_data_cache: OS cache dir unavailable on this platform\"\n                    )\n                })?\n                .join(\"wtf.tonho.omniget\")\n        };\n        let dir = base.join(\"external-cache\").join(plugin_id).join(namespace);\n        std::fs::create_dir_all(&dir).map_err(|e| {\n            anyhow::anyhow!(\n                \"external_data_cache: failed to create {}: {}\",\n                dir.display(),\n                e\n            )\n        })?;\n        Ok(dir)\n    }\n\n    fn get_cookie_file(&self, domain: &str, account: Option<&str>) -> Option<PathBuf> {\n        crate::cookies::account_path_for_consumer(domain, account)","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/plugin_host.rs#L118-L154","documentation":"In non-portable mode external_data_cache uses dirs::cache_dir() to find the OS cache directory; when the platform cannot supply one (or the XDG cache env/home lookup fails) it raises this error. Without an OS cache dir the plugin's external cache cannot be located.","triggerScenarios":"Calling external_data_cache without OMNIGET_PORTABLE on a system where dirs::cache_dir() returns None: Linux without XDG_CACHE_HOME and without a resolvable $HOME, or exotic embedded platform.","commonSituations":"Running the app as a systemd service or cron job with HOME unset on Linux; minimal containers without /home; sandboxed environments stripping env vars.","solutions":["Set XDG_CACHE_HOME (or HOME) in the launch environment before starting the app.","Set OMNIGET_PORTABLE to force the app-data-dir cache base instead.","Run the app in a normal user session where the OS cache dir exists.","Wrap the cache path resolution with a temp-dir fallback for headless/service contexts."],"exampleFix":"// launch environment fix (systemd unit)\n[Service]\nEnvironment=HOME=/home/omniget\nEnvironment=XDG_CACHE_HOME=/home/omniget/.cache","handlingStrategy":"fallback","validationCode":"let has_cache = std::env::var(\"XDG_CACHE_HOME\").is_ok()\n    || std::env::var(\"HOME\").is_ok()\n    || dirs::cache_dir().is_some();\nif !has_cache { eprintln!(\"no OS cache dir; set XDG_CACHE_HOME\"); }","typeGuard":null,"tryCatchPattern":"let dir = host.external_data_cache(pid, ns)\n    .unwrap_or_else(|_| std::env::temp_dir().join(\"omniget-external-cache\").join(pid));","preventionTips":["Always set HOME/XDG_CACHE_HOME when launching from services or containers","Use the portable mode flag as an escape hatch in headless environments","Provide a temp-dir fallback for cache locations"],"tags":["cache-directory","linux","xdg","plugin-host"],"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-23T08:17:48.524Z"}