vectordotdev/vector · error
Could not determine the project directory
Error message
Could not determine the project directory
What it means
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.
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
Example fix
// before (CI step)
- run: cargo vdev build
// after
- run: |
mkdir -p /tmp/vdev-home
HOME=/tmp/vdev-home cargo vdev build Defensive patterns
Strategy: validation
Validate before calling
if [ -z "${HOME:-}" ]; then echo "HOME must be set for vdev to determine its data directory"; exit 1; fi Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- $DOCKER_HOST is not a socket path
- Could not find environment named
- failed to read glob pattern
- global log_schema.message_key to be valid path
- global log_schema.message_key to be valid path
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/ac8fd7b9c95f2dfb.
Report an issue: GitHub.
Appendix: source
Thrown at vdev/src/utils/platform.rs:13
use std::{
env::consts::ARCH,
path::{Path, PathBuf},
sync::OnceLock,
};
use directories::ProjectDirs;
pub fn data_dir() -> &'static Path {
static DATA_DIR: OnceLock<PathBuf> = OnceLock::new();
DATA_DIR.get_or_init(|| {
ProjectDirs::from("", "vector", "vdev")
.expect("Could not determine the project directory")
.data_local_dir()
.to_path_buf()
})
}
pub fn default_target() -> String {
if cfg!(windows) {
format!("{ARCH}-pc-windows-msvc")
} else if cfg!(target_os = "macos") {
format!("{ARCH}-apple-darwin")
} else {
format!("{ARCH}-unknown-linux-gnu")
}
}
View on GitHub (pinned to bdb87aeaa4)