nikivdev/code · error

jj git root returned an empty path

Error message

jj git root returned an empty path

What it means

Error "jj git root returned an empty path" thrown in nikivdev/code.

Source

Thrown at src/jj.rs:203

    let resolved = if path.is_absolute() {
        path.to_path_buf()
    } else {
        std::env::current_dir()
            .context("failed to read current dir")?
            .join(path)
    };
    Ok(resolved.canonicalize().unwrap_or(resolved))
}

fn repo_root_for_workspace(workspace_root: &Path) -> Result<PathBuf> {
    let git_root = jj_read_in(workspace_root, &["git", "root"])?;
    repo_root_from_git_root(git_root.trim()).map(PathBuf::from)
}

fn repo_root_from_git_root(git_root: &str) -> Result<&str> {
    let trimmed = git_root.trim();
    if trimmed.is_empty() {
        bail!("jj git root returned an empty path");
    }
    if let Some(parent) = trimmed.strip_suffix("/.git") {
        return Ok(parent);
    }
    if let Some(parent) = trimmed.strip_suffix("\\.git") {
        return Ok(parent);
    }
    Ok(trimmed)
}

fn run_status(opts: JjStatusOpts) -> Result<()> {
    let workspace_root = vcs::ensure_jj_repo()?;
    let ctx = JjContext {
        repo_root: repo_root_for_workspace(&workspace_root)?,
        workspace_root,
    };
    if opts.raw {
        return jj_run_in(&ctx.workspace_root, &["status"]);

View on GitHub (pinned to a747e741ae)

When it happens

Trigger: Thrown at src/jj.rs:203 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/c767c39f21d07c78. Report an issue: GitHub.