{"record":{"id":"286a648e24c6346c","repo":"vectordotdev/vector","slug":"programfiles-environment-variable-must-be-define","errorCode":null,"errorMessage":"%ProgramFiles% environment variable must be defined","messagePattern":"%ProgramFiles% environment variable must be defined","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/loading/mod.rs","lineNumber":369,"sourceCode":"pub fn load<R: std::io::Read, T>(input: R, format: Format) -> Result<T, Vec<String>>\nwhere\n    T: serde::de::DeserializeOwned,\n{\n    // Via configurations that load from raw string, skip interpolation of env\n    let with_vars = prepare_input(input, false)?;\n\n    representation::deserialize_config(&with_vars, format)\n}\n\n#[cfg(not(windows))]\nfn default_path() -> PathBuf {\n    \"/etc/vector/vector.yaml\".into()\n}\n\n#[cfg(windows)]\nfn default_path() -> PathBuf {\n    let program_files =\n        std::env::var(\"ProgramFiles\").expect(\"%ProgramFiles% environment variable must be defined\");\n    format!(\"{program_files}\\\\Vector\\\\config\\\\vector.yaml\").into()\n}\n\nfn default_config_paths() -> Vec<ConfigPath> {\n    #[cfg(not(windows))]\n    let default_path = default_path();\n    #[cfg(windows)]\n    let default_path = default_path();\n\n    vec![ConfigPath::File(default_path, Some(Format::Yaml))]\n}\n","sourceCodeStart":351,"sourceCodeEnd":381,"githubUrl":"https://github.com/vectordotdev/vector/blob/0d4ab78a4f0d9c9e5d03a50108a2ae4d2f4b2460/src/config/loading/mod.rs#L351-L381","documentation":"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.","triggerScenarios":"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.","commonSituations":"Launching vector from a stripped service context, custom sandbox, container, or parent process that scrubbed the environment; corrupted system environment variables.","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."],"exampleFix":"// before (service env stripped) → panics on default path lookup\n// after\nvector --config C:\\ProgramData\\Vector\\config\\vector.yaml","handlingStrategy":"validation","validationCode":"if std::env::var(\"ProgramFiles\").is_err() {\n    eprintln!(\"ProgramFiles env var missing; pass --config explicitly\");\n}","typeGuard":null,"tryCatchPattern":"// CLI level: always pass --config on Windows hosts with restricted environments\nvector --config \"C:\\\\ProgramData\\\\Vector\\\\config\\\\vector.yaml\"","preventionTips":["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."],"tags":["windows","environment-variable","config"],"backgroundTag":"missing-env-var","analyzedSha":"0d4ab78a4f0d9c9e5d03a50108a2ae4d2f4b2460","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}