{"record":{"id":"f06faee95af195e8","repo":"sxyazi/yazi","slug":"failed-to-get-asset-directory","errorCode":null,"errorMessage":"Failed to get asset directory","messagePattern":"Failed to get asset directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-fs/src/xdg.rs","lineNumber":51,"sourceCode":"\t\t{\n\t\t\tenv::var_os(\"XDG_CONFIG_HOME\")\n\t\t\t\t.map(PathBuf::from)\n\t\t\t\t.filter(|p| p.is_absolute())\n\t\t\t\t.map(|p| p.join(\"yazi\"))\n\t\t\t\t.or_else(|| dirs::home_dir().map(|h| h.join(\".config/yazi\")))\n\t\t\t\t.expect(\"Failed to get config directory\")\n\t\t}\n\t}\n\n\tpub fn asset_dir() -> &'static PathBuf {\n\t\tstatic DIR: LazyLock<PathBuf> = LazyLock::new(Xdg::load_asset_dir);\n\t\t&DIR\n\t}\n\n\tfn load_asset_dir() -> PathBuf {\n\t\t#[cfg(windows)]\n\t\t{\n\t\t\tdirs::cache_dir().map(|p| p.join(\"yazi\")).expect(\"Failed to get asset directory\")\n\t\t}\n\t\t#[cfg(unix)]\n\t\t{\n\t\t\tenv::var_os(\"XDG_CACHE_HOME\")\n\t\t\t\t.map(PathBuf::from)\n\t\t\t\t.filter(|p| p.is_absolute())\n\t\t\t\t.map(|p| p.join(\"yazi\"))\n\t\t\t\t.or_else(|| dirs::home_dir().map(|h| h.join(\".cache/yazi\")))\n\t\t\t\t.expect(\"Failed to get asset directory\")\n\t\t}\n\t}\n\n\tpub fn state_dir() -> &'static PathBuf {\n\t\tstatic DIR: LazyLock<PathBuf> = LazyLock::new(Xdg::load_state_dir);\n\t\t&DIR\n\t}\n\n\tfn load_state_dir() -> PathBuf {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/sxyazi/yazi/blob/a541adde4e5b082719a0f21a87eb3eab071ece58/yazi-fs/src/xdg.rs#L33-L69","documentation":"On Windows, load_asset_dir derives the asset cache dir from dirs::cache_dir() and panics with 'Failed to get asset directory' when the platform cannot supply a cache directory (no known cache location for the user profile).","triggerScenarios":"dirs::cache_dir() returns None — typically a broken or unset USERPROFILE/LOCALAPPDATA environment on Windows.","commonSituations":"Running in stripped service/sandbox environments where LOCALAPPDATA is missing; corrupted user profiles; non-interactive sessions.","solutions":["Ensure LOCALAPPDATA (and USERPROFILE) environment variables are set correctly","Run in an interactive session with a real user profile instead of a service context","Recreate/repair the Windows user profile"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import os\ndef asset_dir_ok():\n    base = os.environ.get(\"LOCALAPPDATA\") or os.environ.get(\"USERPROFILE\")\n    return bool(base and os.path.isdir(base))","typeGuard":null,"tryCatchPattern":"// recover from the panic at process boundary, or set env before launching\nif (!process.env.LOCALAPPDATA) {\n  throw new Error(\"Set LOCALAPPDATA before starting yazi on Windows\");\n}","preventionTips":["Ensure LOCALAPPDATA/USERPROFILE are present in service and CI environments","Launch apps under an interactive user profile, not a bare service account","Pre-set a writable cache location when running in sandboxes"],"tags":["windows","xdg","cache-dir","panic"],"backgroundTag":"missing-env-var","analyzedSha":"a541adde4e5b082719a0f21a87eb3eab071ece58","analyzedAt":"2026-09-18T10:12:31.659Z","contentChangedAt":"2026-09-18T10:12:31.659Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}