nikivdev/code · error · anyhow::Error

No env vars found

Error message

No env vars found

What it means

Raised by the env fetch/pull command after successfully retrieving env vars when the resulting map is empty. Unlike the 404 cases, the fetch succeeded — the server simply returned zero variables for the resolved target and environment. The command treats an empty result as an error condition rather than printing nothing.

Source

Thrown at src/env.rs:3854

    fetch_env_vars(&target, environment, keys, true)
}

pub fn fetch_personal_env_vars(keys: &[String]) -> Result<HashMap<String, String>> {
    let target = resolve_personal_target()?;
    fetch_env_vars(&target, "production", keys, false)
}

/// Get specific env vars and print to stdout.
fn get_vars(keys: &[String], personal: bool, environment: &str, format: &str) -> Result<()> {
    let target = if personal {
        resolve_personal_target()?
    } else {
        resolve_env_target()?
    };
    let vars = fetch_env_vars(&target, environment, keys, !personal)?;

    if vars.is_empty() {
        bail!("No env vars found");
    }

    match format {
        "json" => {
            let json = serde_json::to_string_pretty(&vars)?;
            println!("{}", json);
        }
        "value" => {
            if keys.len() != 1 {
                bail!("'value' format requires exactly one key");
            }
            let key = &keys[0];
            if let Some(value) = vars.get(key) {
                print!("{}", value); // No newline for piping
            } else {
                bail!("Key '{}' not found", key);
            }
        }

View on GitHub (pinned to a747e741ae)

Solutions

  1. Re-run without a --keys filter to see if any vars exist at all.
  2. Push vars with `f env push` if the environment is intentionally empty.
  3. Verify you are fetching from the intended target (personal vs project) and environment name.

Example fix

// before: filtered fetch matches nothing
f env pull --keys API_URL,API_KEY
// after: confirm what exists first
f env pull            // list all vars
f env pull --keys apiUrl
Defensive patterns

Strategy: validation

Validate before calling

# inspect available vars before filtering
f env list            # default env format shows all keys
# only then filter:
f env pull --keys KNOWN_KEY

Try / catch

// shell guard for scripted pulls
VARS=$(f env pull 2>/dev/null) || { echo "no env vars / fetch failed" >&2; exit 1; }
[ -n "$VARS" ] || { echo "environment is empty" >&2; exit 1; }

Prevention

When it happens

Trigger: `f env pull` (or list) where fetch_env_vars returns an empty map: the env set exists but contains no keys, possibly because all keys were deleted or a --keys filter matched nothing.

Common situations: Passing --keys with key names that don't exist remotely; someone wiped the environment's vars; pointing at an empty newly-created environment.

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


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/6f943fbedc18a15b. Report an issue: GitHub.