nikivdev/code · error

Unable to resolve git root.

Error message

Unable to resolve git root.

What it means

Error "Unable to resolve git root." thrown in nikivdev/code.

Source

Thrown at src/changes.rs:76

        None => {
            let env_keys = normalize_env_keys(&cmd.env)?;
            trace(&format!("create bundle (env keys: {})", env_keys.len()));
            create_bundle(&env_keys)
        }
    }
}

fn repo_root() -> Result<PathBuf> {
    let output = Command::new("git")
        .args(["rev-parse", "--show-toplevel"])
        .output()
        .context("failed to run git rev-parse")?;
    if !output.status.success() {
        bail!("Not a git repository.");
    }
    let root = String::from_utf8_lossy(&output.stdout).trim().to_string();
    if root.is_empty() {
        bail!("Unable to resolve git root.");
    }
    trace(&format!("repo root: {}", root));
    Ok(PathBuf::from(root))
}

fn git_output_in(repo_root: &Path, args: &[&str]) -> Result<(String, bool)> {
    let output = Command::new("git")
        .current_dir(repo_root)
        .args(args)
        .output()
        .with_context(|| format!("failed to run git {}", args.join(" ")))?;
    let stdout = String::from_utf8_lossy(&output.stdout).to_string();
    let stderr = String::from_utf8_lossy(&output.stderr).to_string();
    let ok = output.status.success();
    if !ok && stdout.is_empty() {
        bail!("git {} failed: {}", args.join(" "), stderr.trim());
    }
    Ok((stdout, ok))

View on GitHub (pinned to a747e741ae)

When it happens

Trigger: Thrown at src/changes.rs:76 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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