astrid-runtime/astrid · error

--var names no [env] field in {capsule_id}: {key}

Error message

--var names no [env] field in {capsule_id}: {key}

What it means

In headless (non-interactive) install, write_headless_env_fields validates every value passed via --var against the capsule manifest's declared [env] fields. A --var key that is not declared in the manifest is rejected, since headless mode cannot prompt for or invent undefined fields.

Source

Thrown at crates/astrid-cli/src/commands/capsule/install_headless.rs:27

use astrid_events::{AstridEvent, EventBus, EventMetadata, EventReceiver};
use astrid_types::Topic;
use astrid_types::ipc::{IpcMessage, IpcPayload, OnboardingFieldType};

use super::install_prompts::order_env_keys;

/// Persist manifest configuration supplied to `capsule install --yes` without
/// reading stdin. Existing values are preserved unless the operator explicitly
/// supplies a replacement. Secret and text values use typed daemon control
/// namespaces.
pub(crate) fn write_headless_env_fields(
    env_defs: &HashMap<String, EnvDef>,
    capsule_id: &str,
    principal: &PrincipalId,
    vars: &HashMap<String, String>,
) -> anyhow::Result<()> {
    for key in vars.keys() {
        if !env_defs.contains_key(key) {
            anyhow::bail!("--var names no [env] field in {capsule_id}: {key}");
        }
    }

    let existing = list_env_entries(principal, capsule_id)?;
    let existing_keys: std::collections::HashSet<String> =
        existing.into_iter().map(|entry| entry.key).collect();

    for key in order_env_keys(env_defs) {
        let def = &env_defs[&key];
        let env_key = headless_env_key(&key);
        let supplied = vars
            .get(&key)
            .cloned()
            .or_else(|| std::env::var(&env_key).ok());
        if supplied.is_none() && existing_keys.contains(&key) {
            continue;
        }
        let resolved = supplied

View on GitHub (pinned to affd8760f4)

Solutions

  1. Check the capsule manifest's [env] section (or its docs) for the exact field name and correct the --var spelling.
  2. Remove the --var flag if the field is no longer declared in this capsule version.
  3. Confirm you installed the capsule version you expect — field names may differ between versions.

Example fix

// before
astrid capsule install github:org/repo --var api-token=xxx   # manifest declares api_token
// after
astrid capsule install github:org/repo --var api_token=xxx
Defensive patterns

Strategy: validation

Validate before calling

// validate --var keys against the manifest's [env] section before installing
let declared: HashSet<&str> = manifest.env.keys().map(|k| k.as_str()).collect();
for key in var_flags.keys() {
    assert!(declared.contains(key.as_str()), "undeclared --var: {key}");
}

Prevention

When it happens

Trigger: finish_install invokes write_headless_env_fields with a --var key absent from the capsule's [env] definitions in its manifest.

Common situations: Typo in a --var key name; installing a newer/older capsule version where the env field was renamed or removed; copying --var flags from a different capsule's docs.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/fd1937df33abde08. Report an issue: GitHub.