astrid-runtime/astrid · error
--var '{key}' was supplied more than once
Error message
--var '{key}' was supplied more than once What it means
validate_values inserts each parsed key into a HashMap; if insert returns Some, the same key appeared in more than one --var flag. Duplicate keys are ambiguous, so the install bails instead of silently last-wins.
Source
Thrown at crates/astrid-cli/src/commands/capsule/install_daemon.rs:420
.with_context(|| format!("read Capsule.toml from {}", path.display()));
}
bail!("source path does not exist: {source}")
}
fn validate_values(
manifest: &CapsuleManifest,
items: &[String],
) -> anyhow::Result<Vec<DaemonEnvValue>> {
let mut parsed = HashMap::new();
for item in items {
let (key, value) = item
.split_once('=')
.ok_or_else(|| anyhow::anyhow!("--var must be KEY=VALUE (got {item:?})"))?;
if key.is_empty() || key.contains('\0') || key.contains(':') {
bail!("--var has an invalid key (got {key:?})");
}
if parsed.insert(key.to_owned(), value.to_owned()).is_some() {
bail!("--var '{key}' was supplied more than once");
}
}
let mut values = Vec::with_capacity(parsed.len());
for (key, value) in parsed {
let definition = manifest.env.get(&key).ok_or_else(|| {
anyhow::anyhow!(
"--var names no [env] field in {}: {key}",
manifest.package.name
)
})?;
let kind = if definition.env_type.eq_ignore_ascii_case("secret") {
if value.len() > 64 * 1024 {
bail!("secret value for {key} exceeds 65536-byte limit");
}
EnvValueKind::Secret
} else {
if value.len() > 1 << 20 {View on GitHub (pinned to affd8760f4)
Solutions
- Remove the duplicate --var occurrence, keeping only the intended value.
- Deduplicate the key list in your script before building the command.
- If you meant to override, decide which value wins and pass it once.
Example fix
// before --var TOKEN=a --var TOKEN=b // after --var TOKEN=b
Defensive patterns
Strategy: validation
Validate before calling
let seen = std::collections::HashSet::new();
for k in keys { assert!(seen.insert(k), "duplicate --var key {k}"); } Try / catch
on duplicate-key error, de-duplicate the argument list (last-wins intentionally) and re-run once.
Prevention
- Build --var flags from a single source of truth (one map/file).
- Deduplicate key lists before looping them into flags.
- Avoid merging defaults and explicit flags without an override policy.
When it happens
Trigger: Supplying the same env key twice, e.g. --var TOKEN=a --var TOKEN=b, to install_local_via_daemon_for_target_with_generation.
Common situations: Shell scripts appending --var flags in a loop over a list containing duplicate keys; combining a defaults file and explicit flags that both define the same key.
Related errors
- --var has an invalid key (got {key:?})
- --var must be KEY=VALUE (got {item:?})
- --var has an empty key (got {item:?})
- environment value for {key} exceeds 1048576-byte limit
- invalid value for {}.{}: expected one of {}, got {value:?}
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/5e2dab2f506ae239.
Report an issue: GitHub.