vectordotdev/vector · error
Required environment variables are not set
Error message
Required environment variables are not set: {missing} What it means
`check_required` validates that every environment variable declared in the integration test config is set before starting containers. If any are missing, it collects the names and bails with a joined list. This ensures integration environments have the credentials/settings they need up front.
Solutions
- Export each variable listed in the error message, e.g. `export AWS_ACCESS_KEY_ID=...`
- Source your env file: `set -a; source .env; set +a` or use direnv
- In CI, configure the secrets as environment variables on the job
- Remove the variable from the environment's required list only if it is genuinely not needed
Example fix
// before export AWS_ACCESS_KEY_ID=... # AWS_SECRET_ACCESS_KEY missing // after export AWS_ACCESS_KEY_ID=... export AWS_SECRET_ACCESS_KEY=...
Defensive patterns
Strategy: validation
Validate before calling
const REQUIRED: &[&str] = &["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"];
let missing: Vec<_> = REQUIRED.iter().filter(|v| std::env::var(v).is_err()).collect();
assert!(missing.is_empty(), "missing: {:?}", missing); Prevention
- Keep a .env file (gitignored) with all required integration variables and source it before testing
- Use direnv or similar to load variables automatically per directory
- In CI, wire all required secrets into the job environment
- Run the integration check early in scripts to fail fast before builds
When it happens
Trigger: Calling `ComposeTest::start()` (or the config's `check_required()`) when at least one env var listed in the environment's `required` section is unset in the shell.
Common situations: Forgetting to export AWS credentials for the aws integration; running integration tests in CI without secret injection; switching shells where env vars were set only in another profile.
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
- Could not find environment named
- Integration has no environments
- environment is already up
- global log_schema.message_key to be valid path
- Invalid `ack_decoding` config.
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/87cbaaf07c325243.
Report an issue: GitHub.
Appendix: source
Thrown at vdev/src/testing/config.rs:285
Self::collect_all_dir(&tests_dir, &mut configs, use_config_subdir)?;
Ok(configs)
}
/// Ensure that all passthrough environment variables are set.
pub fn check_required(&self) -> Result<()> {
let missing: Vec<_> = self
.env
.iter()
.chain(self.runner.env.iter())
.filter_map(|(key, value)| value.is_none().then_some(key))
.filter(|var| env::var(var).is_err())
.collect();
if missing.is_empty() {
Ok(())
} else {
let missing = missing.into_iter().join(", ");
bail!("Required environment variables are not set: {missing}");
}
}
}
View on GitHub (pinned to bdb87aeaa4)