nikivdev/code · error

'codanna index' exited with status {}

Error message

'codanna index' exited with status {}

What it means

run_codanna_index spawns `codanna index` as a subprocess to build/update the code index. If the spawned process completes but exits with a non-zero status, the exit code is surfaced through this bail!. Spawn errors are reported separately ('failed to spawn'), so this error means codanna's indexing itself failed.

Source

Thrown at src/indexer.rs:84

            status.code().unwrap_or(-1)
        );
    }
}

fn run_codanna_index(binary: &Path, project_root: &Path) -> Result<()> {
    println!("Indexing project {} via Codanna...", project_root.display());
    let status = Command::new(binary)
        .arg("index")
        .arg("--progress")
        .arg(".")
        .current_dir(project_root)
        .status()
        .with_context(|| "failed to spawn 'codanna index'")?;

    if status.success() {
        Ok(())
    } else {
        bail!(
            "'codanna index' exited with status {}",
            status.code().unwrap_or(-1)
        );
    }
}

fn capture_index_stats(binary: &Path, project_root: &Path) -> Result<String> {
    println!("Fetching Codanna index metadata...");
    let output = Command::new(binary)
        .arg("mcp")
        .arg("get_index_info")
        .arg("--json")
        .current_dir(project_root)
        .output()
        .with_context(|| "failed to run 'codanna mcp get_index_info --json'")?;

    if !output.status.success() {
        let stderr = String::from_utf8_lossy(&output.stderr);

View on GitHub (pinned to a747e741ae)

Solutions

  1. Run `codanna index` manually in the project root to see the real error output.
  2. Ensure `codanna init` completed successfully for this project before indexing.
  3. Update codanna to the latest version and retry.
  4. Check write permissions on the project directory/index storage location.
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure init ran and codanna exists before indexing
assert!(which::which("codanna").is_ok(), "codanna missing from PATH");
assert!(Path::new(".codanna").exists() || Path::new("codanna.json").exists(),
        "project not initialized; run codanna init first");

Try / catch

if let Err(e) = run_indexer() {
    let msg = e.to_string();
    if msg.contains("'codanna index' exited") {
        eprintln!("indexing failed; run `codanna index` manually for details: {msg}");
    } else {
        return Err(e.into());
    }
}

Prevention

When it happens

Trigger: Running the indexer when `codanna index` fails inside the project, e.g. unindexable source tree, codanna internal error, or missing index configuration after init.

Common situations: Source directory contains files codanna cannot parse; codanna was never initialized for the project; disk/permission errors while writing the index; incompatible codanna version.

Related errors


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