nikivdev/code · error

repo URL is required

Error message

repo URL is required

What it means

parse_repo_input normalizes user-supplied repo identifiers (SSH scp-style URLs, HTTPS URLs, owner/repo shorthands) into a RepoInput. An empty string (after trimming whitespace and trailing slashes) cannot identify any repository, so it bails with this message.

Source

Thrown at src/home.rs:793

        if flat.is_some() {
            return Ok(flat);
        }
    }
    Ok(None)
}

fn derive_internal_repo(repo: &RepoInput) -> Option<String> {
    let suffix = format!("{}-i", repo.repo);
    match repo.scheme {
        RepoScheme::Https => Some(format!("https://github.com/{}/{}.git", repo.owner, suffix)),
        RepoScheme::Ssh => Some(format!("git@github.com:{}/{}.git", repo.owner, suffix)),
    }
}

fn parse_repo_input(input: &str) -> Result<RepoInput> {
    let trimmed = input.trim().trim_end_matches('/');
    if trimmed.is_empty() {
        bail!("repo URL is required");
    }

    if let Some(rest) = trimmed.strip_prefix("git@github.com:") {
        return parse_owner_repo(rest, RepoScheme::Ssh);
    }

    if let Some(rest) = trimmed.strip_prefix("ssh://git@github.com/") {
        return parse_owner_repo(rest, RepoScheme::Ssh);
    }

    if let Some(rest) = trimmed.strip_prefix("https://github.com/") {
        return parse_owner_repo(rest, RepoScheme::Https);
    }

    if let Some(rest) = trimmed.strip_prefix("http://github.com/") {
        return parse_owner_repo(rest, RepoScheme::Https);
    }

View on GitHub (pinned to a747e741ae)

Solutions

  1. Set the repo URL in the config (home.toml) or pass it explicitly on the command line
  2. Check that the env var feeding the value is actually set/non-empty
  3. Use owner/repo shorthand, e.g. `owner/repo`, `git@github.com:owner/repo.git`, or an HTTPS URL

Example fix

// before (home.toml)
repo_url = ""
// after
repo_url = "owner/kar"
Defensive patterns

Strategy: validation

Validate before calling

let repo_url = std::env::var("REPO_URL")?;
if repo_url.trim().trim_end_matches('/').is_empty() {
    bail!("REPO_URL must be non-empty (use owner/repo or a GitHub URL)");
}

Type guard

fn non_empty_repo_input(s: &str) -> Option<&str> {
    let t = s.trim().trim_end_matches('/');
    if t.is_empty() { None } else { Some(t) }
}

Try / catch

match parse_repo_input(input) {
    Err(e) if e.to_string() == "repo URL is required" => {
        eprintln!("provide --repo owner/name or set repo_url in config");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling run, ensure_kar_repo, or coerce_repo_input with an empty/unset repo URL string that reaches parse_repo_input as "" or only whitespace/slashes.

Common situations: Missing repo_url in home.toml / config; environment variable interpolating to empty; blank CLI argument; read_internal_repo returning None and an empty default being passed through.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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