nikivdev/code · error · anyhow::Error

Project not found. Create it with `f env push` first.

Error message

Project not found. Create it with `f env push` first.

What it means

Raised when the cloud API returns 404 while fetching env vars for an EnvTarget::Project target. It means the project (as resolved from the local project config) does not exist server-side. The message explicitly directs the user to create it by pushing env vars.

Source

Thrown at src/env.rs:3800

        .header("Authorization", format!("Bearer {}", token))
        .send()
        .context("failed to connect to cloud")?;

    if resp.status() == 401 {
        if std::io::stdin().is_terminal()
            && prompt_confirm("Cloud auth failed. Read local envs instead? (y/N): ")?
        {
            let vars = read_local_env_vars(target, environment)?;
            return Ok(select_requested_env_keys(vars, keys));
        }
        bail!("Unauthorized. Check your token with `f env login`.");
    }

    if resp.status() == 404 {
        match target {
            EnvTarget::Personal { .. } => bail!("Personal env vars not found."),
            EnvTarget::Project { .. } => {
                bail!("Project not found. Create it with `f env push` first.")
            }
        }
    }

    if !resp.status().is_success() {
        let status = resp.status();
        let body = resp.text().unwrap_or_default();
        let err = anyhow::anyhow!("API error {}: {}", status, body);
        if is_local_fallback_error(&err)
            && std::io::stdin().is_terminal()
            && prompt_confirm("Cloud unavailable. Read local envs instead? (y/N): ")?
        {
            let vars = read_local_env_vars(target, environment)?;
            return Ok(select_requested_env_keys(vars, keys));
        }
        return Err(err);
    }

View on GitHub (pinned to a747e741ae)

Solutions

  1. Run `f env push` in the project to create the project and its env vars, then retry the pull.
  2. Check the project name/id in local config matches the project on the server.
  3. If the project was renamed/deleted remotely, update local config to the correct project and re-authenticate if needed.

Example fix

// before: fresh clone, project never registered
f env pull
// after
f env push   # registers project + uploads vars
f env pull
Defensive patterns

Strategy: fallback

Validate before calling

# verify project registration first
f env list || { echo 'project not registered; run f env push'; exit 1; }

Try / catch

// auto-register on first 404
if let Err(e) = fetch_project_vars(&project, env) {
    if e.to_string().contains("Project not found") {
        run("f env push")?;
        return fetch_project_vars(&project, env);
    }
    return Err(e);
}

Prevention

When it happens

Trigger: Running a fetch against project-scope env vars where the project name/id in local config has never been registered via `f env push`, so the API responds 404.

Common situations: Cloning a repo and pulling envs before anyone pushed them; local project config pointing at a renamed or deleted project; working in a fresh project directory where `f env push` was never run.

Related errors


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