nikivdev/code · error

repo URL required

Error message

{} repo URL required

What it means

ensure_repo clones a repo when the destination is missing and requires a repo URL for that case; it throws when the repo is absent from dest and no repo_url argument was supplied. When the repo already exists it just updates, so the URL is optional then.

Solutions

  1. Provide the repo URL in config or the command argument for that label
  2. Pre-clone the repo into dest so only update_repo runs
  3. Run the setup/init command that populates default repo URLs

Example fix

// before
f home sync mylabel            // no URL known
// after
f home sync mylabel --repo https://github.com/org/mylabel.git
Defensive patterns

Strategy: validation

Validate before calling

let dest_exists = dest.join(".git").exists();
if !dest_exists && repo_url.is_none() {
    anyhow::bail!("{} repo not cloned and no repo URL configured", label);
}

Try / catch

match ensure_repo(label, dest, repo_url) {
    Err(e) if e.to_string().ends_with("repo URL required") => {
        eprintln!("add repo url for {} to config", label);
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling ensure_repo (via `run` or ensure_kar_repo) with a label/dest where the repo isn't cloned yet and repo_url is None.

Common situations: First run on a fresh machine without the URL configured, config missing the repo URL field for the labeled repo, deleted destination directory.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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

Appendix: source

Thrown at src/home.rs:592

            if allow_origin_reset {
                ensure_origin_url(dest, expected)?;
            } else if let Ok(actual) = git_capture(dest, &["remote", "get-url", "origin"]) {
                if !urls_match(expected, actual.trim()) {
                    bail!(
                        "{} origin mismatch: expected {}, got {}",
                        label,
                        expected,
                        actual.trim()
                    );
                }
            }
        }

        update_repo(dest)?;
        return Ok(());
    }

    let repo_url = repo_url.ok_or_else(|| anyhow::anyhow!("{} repo URL required", label))?;
    clone_repo(repo_url, dest)?;
    Ok(())
}

fn update_repo(dest: &Path) -> Result<()> {
    run_command("git", &["fetch", "--prune", "origin"], Some(dest))?;
    let branch = default_branch(dest)?;
    run_command(
        "git",
        &["checkout", "-B", &branch, &format!("origin/{}", branch)],
        Some(dest),
    )?;
    run_command(
        "git",
        &["reset", "--hard", &format!("origin/{}", branch)],
        Some(dest),
    )?;
    println!("Updated {}", dest.display());

View on GitHub (pinned to a747e741ae)