{"record":{"id":"ac8fd7b9c95f2dfb","repo":"vectordotdev/vector","slug":"could-not-determine-the-project-directory","errorCode":null,"errorMessage":"Could not determine the project directory","messagePattern":"Could not determine the project directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/utils/platform.rs","lineNumber":13,"sourceCode":"use std::{\n    env::consts::ARCH,\n    path::{Path, PathBuf},\n    sync::OnceLock,\n};\n\nuse directories::ProjectDirs;\n\npub fn data_dir() -> &'static Path {\n    static DATA_DIR: OnceLock<PathBuf> = OnceLock::new();\n    DATA_DIR.get_or_init(|| {\n        ProjectDirs::from(\"\", \"vector\", \"vdev\")\n            .expect(\"Could not determine the project directory\")\n            .data_local_dir()\n            .to_path_buf()\n    })\n}\n\npub fn default_target() -> String {\n    if cfg!(windows) {\n        format!(\"{ARCH}-pc-windows-msvc\")\n    } else if cfg!(target_os = \"macos\") {\n        format!(\"{ARCH}-apple-darwin\")\n    } else {\n        format!(\"{ARCH}-unknown-linux-gnu\")\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/utils/platform.rs#L1-L28","documentation":"vdev's data_dir() locates a persistent per-user data directory via the `directories` crate (ProjectDirs::from(\"\", \"vector\", \"vdev\")). On platforms where the XDG spec or OS conventions cannot supply a data-local dir (notably when $HOME is unset on Linux, or on unsupported platforms), ProjectDirs::from returns None and this expect panics. It is a fatal environment problem, not a bug in vdev itself.","triggerScenarios":"Calling any vdev command that persists state (caches, downloaded artifacts) while $HOME is unset or empty in a Linux/Unix environment, or running on a platform where the directories crate cannot derive base directories.","commonSituations":"CI jobs or systemd units running with a sanitized environment missing $HOME; running as a user with no passwd entry (nobody); minimal Docker containers where HOME is not set; sudo -i / su misconfiguration clearing HOME.","solutions":["Set a writable HOME environment variable before running vdev, e.g. HOME=/home/runner or HOME=/tmp/vdev-home (mkdir it first)","If running under sudo, preserve HOME (sudo -E) or run as a normal user","In containers/CI, create and assign a home directory for the executing user","Check that the platform is supported (Linux/macOS/Windows) by the directories crate"],"exampleFix":"// before (CI step)\n- run: cargo vdev build\n// after\n- run: |\n    mkdir -p /tmp/vdev-home\n    HOME=/tmp/vdev-home cargo vdev build","handlingStrategy":"validation","validationCode":"if [ -z \"${HOME:-}\" ]; then echo \"HOME must be set for vdev to determine its data directory\"; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run vdev as a user with a home directory","In CI/systemd units, explicitly set HOME in the environment","In Dockerfiles, set ENV HOME=/root or create a user with a home dir","Avoid `sudo -i` / env sanitizers that strip HOME"],"tags":["environment","configuration","platform"],"backgroundTag":"missing-env-var","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}