vectordotdev/vector · error
%ProgramFiles% environment variable must be defined
Error message
%ProgramFiles% environment variable must be defined
What it means
On Windows, `default_path` builds the default config location from the `%ProgramFiles%` environment variable and asserts it is defined. The panic means Windows is running without this standard environment variable set, so the default config path cannot be computed.
Solutions
- Pass an explicit `--config <path>` so the default path is never computed.
- Restore the `ProgramFiles` environment variable (typically `C:\Program Files`) in the launching context.
- Fix the service/scheduler definition (e.g. NSSM, Task Scheduler) so it inherits the normal system environment.
Example fix
// before (service env stripped) → panics on default path lookup // after vector --config C:\ProgramData\Vector\config\vector.yaml
Defensive patterns
Strategy: validation
Validate before calling
if std::env::var("ProgramFiles").is_err() {
eprintln!("ProgramFiles env var missing; pass --config explicitly");
} Try / catch
// CLI level: always pass --config on Windows hosts with restricted environments vector --config "C:\\ProgramData\\Vector\\config\\vector.yaml"
Prevention
- Always pass --config explicitly in Windows services and containers.
- Ensure service wrappers (NSSM, Task Scheduler) inherit the full system environment.
- Verify `echo %ProgramFiles%` works in the launch context before deploying.
When it happens
Trigger: Running vector (or anything calling `default_config_paths`/config loading without an explicit `--config`) on Windows where the `ProgramFiles` env var is missing or unset in the process environment.
Common situations: Launching vector from a stripped service context, custom sandbox, container, or parent process that scrubbed the environment; corrupted system environment variables.
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
- {}
- completing more than 2^16 data files at a time is obviously…
- {}
- config should not have any errors
- Couldn't parse default API URL. Please report this.
AI-assisted analysis of vectordotdev/vector@0d4ab78a4f (2026-09-16).
Data as JSON: /api/errors/286a648e24c6346c.
Report an issue: GitHub.
Appendix: source
Thrown at src/config/loading/mod.rs:369
pub fn load<R: std::io::Read, T>(input: R, format: Format) -> Result<T, Vec<String>>
where
T: serde::de::DeserializeOwned,
{
// Via configurations that load from raw string, skip interpolation of env
let with_vars = prepare_input(input, false)?;
representation::deserialize_config(&with_vars, format)
}
#[cfg(not(windows))]
fn default_path() -> PathBuf {
"/etc/vector/vector.yaml".into()
}
#[cfg(windows)]
fn default_path() -> PathBuf {
let program_files =
std::env::var("ProgramFiles").expect("%ProgramFiles% environment variable must be defined");
format!("{program_files}\\Vector\\config\\vector.yaml").into()
}
fn default_config_paths() -> Vec<ConfigPath> {
#[cfg(not(windows))]
let default_path = default_path();
#[cfg(windows)]
let default_path = default_path();
vec![ConfigPath::File(default_path, Some(Format::Yaml))]
}
View on GitHub (pinned to 0d4ab78a4f)