{"record":{"id":"9e76a4f832d5a08e","repo":"BloopAI/vibe-kanban","slug":"os-didn-t-give-us-a-home-directory-9e76a4","errorCode":null,"errorMessage":"OS didn't give us a home directory","messagePattern":"OS didn't give us a home directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/utils/src/lib.rs","lineNumber":54,"sourceCode":"        }\n\n        // Check /proc/version for WSL2 signature\n        if let Ok(version) = std::fs::read_to_string(\"/proc/version\")\n            && (version.contains(\"WSL2\") || version.contains(\"microsoft\"))\n        {\n            tracing::debug!(\"WSL2 detected via /proc/version\");\n            return true;\n        }\n\n        tracing::debug!(\"WSL2 not detected\");\n        false\n    })\n}\n\npub fn cache_dir() -> std::path::PathBuf {\n    let proj = if cfg!(debug_assertions) {\n        ProjectDirs::from(\"ai\", \"bloop-dev\", env!(\"CARGO_PKG_NAME\"))\n            .expect(\"OS didn't give us a home directory\")\n    } else {\n        ProjectDirs::from(\"ai\", \"bloop\", env!(\"CARGO_PKG_NAME\"))\n            .expect(\"OS didn't give us a home directory\")\n    };\n\n    // ✔ macOS → ~/Library/Caches/MyApp\n    // ✔ Linux → ~/.cache/myapp (respects XDG_CACHE_HOME)\n    // ✔ Windows → %LOCALAPPDATA%\\Example\\MyApp\n    proj.cache_dir().to_path_buf()\n}\n\n// Get or create cached PowerShell script file\npub async fn get_powershell_script()\n-> Result<std::path::PathBuf, Box<dyn std::error::Error + Send + Sync>> {\n    use std::io::Write;\n\n    let cache_dir = cache_dir();\n    let script_path = cache_dir.join(\"toast-notification.ps1\");","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/crates/utils/src/lib.rs#L36-L72","documentation":"cache_dir() panics when directories::ProjectDirs::from returns None in the debug_assertions branch (qualifier \"ai\", organization \"bloop-dev\"). This happens when the OS cannot supply a home/base directory, so the Option is None and expect(\"OS didn't give us a home directory\") fires. The qualifier difference is irrelevant to the failure — only the missing home directory matters.","triggerScenarios":"Calling cache_dir() (or get_powershell_script, which calls cache_dir) in a debug build where ProjectDirs::from(\"ai\", \"bloop-dev\", ...) returns None — $HOME unset/empty on Linux or missing profile/appdata env vars on Windows.","commonSituations":"Local dev under a stripped environment: `env -i cargo run`, cron/systemd timers without HOME, Docker dev containers with a non-existent user (no passwd entry), CI runners with minimal env.","solutions":["Set $HOME in your shell/service environment before running a debug build.","Set $XDG_CACHE_HOME as an explicit override.","If running as a container user not in /etc/passwd, add the user or set HOME manually.","Refactor cache_dir() to return Result and fall back to std::env::temp_dir().join(env!(\"CARGO_PKG_NAME\")) when ProjectDirs is None."],"exampleFix":"// before\nlet proj = if cfg!(debug_assertions) {\n    ProjectDirs::from(\"ai\", \"bloop-dev\", env!(\"CARGO_PKG_NAME\"))\n        .expect(\"OS didn't give us a home directory\")\n} else {\n    ProjectDirs::from(\"ai\", \"bloop\", env!(\"CARGO_PKG_NAME\"))\n        .expect(\"OS didn't give us a home directory\")\n};\n// after\nlet proj = ProjectDirs::from(\"ai\", \"bloop-dev\", env!(\"CARGO_PKG_NAME\"))\n    .with_context(|| \"cannot resolve home directory: is $HOME set?\")?;","handlingStrategy":"validation","validationCode":"// before calling cache_dir() in a debug build\nif std::env::var_os(\"HOME\").map(|v| v.is_empty()).unwrap_or(true)\n    && std::env::var_os(\"XDG_CACHE_HOME\").is_none()\n{\n    eprintln!(\"HOME/XDG_CACHE_HOME unset: cache_dir() will panic; set them first\");\n}","typeGuard":null,"tryCatchPattern":"let dir = std::panic::catch_unwind(vibe_utils::cache_dir)\n    .unwrap_or_else(|_| std::env::temp_dir().join(\"vibe-kanban-dev\"));","preventionTips":["Set HOME (or XDG_CACHE_HOME) in dev shells, Makefiles, and dev containers.","Check `echo $HOME` is non-empty when running under cron, systemd, or SSH with env_reset.","In dev containers, define the user in the Dockerfile instead of relying on a bare numeric UID.","Wrap cache_dir() once at startup and store the resolved path instead of calling it ad hoc."],"tags":["filesystem","panic","environment","rust"],"backgroundTag":"home-directory-not-found","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}