nikivdev/code · error

flow repo not found at {}

Error message

flow repo not found at {}

What it means

flow_repo_root resolves the developer's local `~/code/flow` checkout. If the home directory resolves but the `code/flow` path does not exist on disk, it bails with this error naming the missing path. It is an environment precondition check before updating the flow repo.

Source

Thrown at src/latest.rs:22

use anyhow::{Context, Result, bail};

use crate::cli::DeployCommand;
use crate::deploy;

pub fn run() -> Result<()> {
    let flow_root = flow_repo_root()?;
    update_flow_repo(&flow_root)?;
    rebuild_flow(&flow_root)?;
    reload_fish_shell()?;
    Ok(())
}

fn flow_repo_root() -> Result<PathBuf> {
    let root = dirs::home_dir()
        .context("failed to resolve home directory")?
        .join("code/flow");
    if !root.exists() {
        bail!("flow repo not found at {}", root.display());
    }
    Ok(root)
}

fn update_flow_repo(root: &PathBuf) -> Result<()> {
    println!("Updating {}", root.display());
    let status = Command::new("git")
        .args([
            "-C",
            root.to_str().unwrap_or(""),
            "pull",
            "--rebase",
            "--autostash",
        ])
        .stdin(Stdio::inherit())
        .stdout(Stdio::inherit())
        .stderr(Stdio::inherit())
        .status()

View on GitHub (pinned to a747e741ae)

Solutions

  1. Clone the flow repository to `~/code/flow` (git clone <flow-repo-url> ~/code/flow)
  2. If the repo lives elsewhere, create a symlink: ln -s /actual/path/flow ~/code/flow
  3. Verify HOME is set to the expected user's home and that ~/code/flow exists (ls ~/code/flow)

Example fix

// before (fails on fresh machine)
bail!("flow repo not found at {}", root.display());
// after (make the root configurable)
let root = std::env::var("FLOW_REPO")
    .map(PathBuf::from)
    .unwrap_or_else(|_| dirs::home_dir().unwrap().join("code/flow"));
Defensive patterns

Strategy: validation

Validate before calling

let root = dirs::home_dir().unwrap().join("code/flow");
if !root.exists() {
    eprintln!("flow repo missing at {} — clone it first", root.display());
    std::process::exit(1);
}

Type guard

fn flow_repo_present() -> bool {
    dirs::home_dir().map(|h| h.join("code/flow").is_dir()).unwrap_or(false)
}

Try / catch

match flow_repo_root() {
    Ok(root) => update_flow_repo(&root)?,
    Err(e) if e.to_string().contains("flow repo not found") => {
        eprintln!("Hint: clone the flow repo to ~/code/flow");
        return Err(e);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling run (which calls flow_repo_root) when `~/.cargo`-style home is resolved via dirs::home_dir() but `$HOME/code/flow` does not exist — e.g. fresh machine, repo cloned elsewhere, or HOME pointing at a different user.

Common situations: New workstation setup without cloning the flow repo; flow repo moved to a non-default location; running the tool in CI or a container where HOME differs; typo'd/renamed checkout directory.

Related errors


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