{"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":357,"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!(\"{}\\\\Vector\\\\config\\\\vector.yaml\", program_files).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":339,"sourceCodeEnd":369,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/config/loading/mod.rs#L339-L369","documentation":"On Windows, Vector's default config path is derived from the %ProgramFiles% environment variable: std::env::var(\"ProgramFiles\").expect(\"%ProgramFiles% environment variable must be defined\") (src/config/loading/mod.rs). This Windows-only code runs when no --config is given and default discovery kicks in; if the environment lacks ProgramFiles (normally set by Windows as a system variable), startup panics while computing the default path.","triggerScenarios":"Running vector.exe with no -c/--config/VECTOR_CONFIG on Windows under an environment where ProgramFiles was stripped — cleared env blocks, some service wrappers/Job schedulers, minimal containers (Windows Server containers), ssh sessions with sanitized environments, or processes spawned with env -i.","commonSituations":"Running Vector as a Windows service or scheduled task whose environment block omits system variables; CI runners that sanitize env; Windows containers with deliberately minimal images; scripts that clear the environment before exec.","solutions":["Pass the config path explicitly so default_path() is never consulted: vector --config C:\\\\Vector\\\\config\\\\vector.yaml (also set the Windows service binPath arguments)","Restore the system variable in the launching environment: setx ProgramFiles \"C:\\\\Program Files\" /M (admin) or set it in the service wrapper's environment","If using sanitized envs by design, export ProgramFiles yourself before launching vector.exe","For the service install, reinstall via vector service install which registers proper arguments including the config path"],"exampleFix":"rem before (no config given, stripped environment)\nvector\n\nrem after (explicit config path, no env dependency)\nvector --config C:\\Vector\\config\\vector.yaml","handlingStrategy":"validation","validationCode":"// Windows: check the variable before launching without an explicit config\n#[cfg(windows)]\nfn can_use_default_path() -> bool {\n    std::env::var(\"ProgramFiles\").is_ok()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --config explicitly in Windows service/CI environments","Ensure service wrappers and schedulers inherit system environment variables","Set ProgramFiles explicitly in sanitized environments before launching vector.exe"],"tags":["vector","windows","environment-variables","startup","config","panic"],"backgroundTag":"missing-env-var","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}