{"record":{"id":"77884555fc0c688d","repo":"nikivdev/code","slug":"codanna-index-exited-with-status","errorCode":null,"errorMessage":"'codanna index' exited with status {}","messagePattern":"'codanna index' exited with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/indexer.rs","lineNumber":84,"sourceCode":"            status.code().unwrap_or(-1)\n        );\n    }\n}\n\nfn run_codanna_index(binary: &Path, project_root: &Path) -> Result<()> {\n    println!(\"Indexing project {} via Codanna...\", project_root.display());\n    let status = Command::new(binary)\n        .arg(\"index\")\n        .arg(\"--progress\")\n        .arg(\".\")\n        .current_dir(project_root)\n        .status()\n        .with_context(|| \"failed to spawn 'codanna index'\")?;\n\n    if status.success() {\n        Ok(())\n    } else {\n        bail!(\n            \"'codanna index' exited with status {}\",\n            status.code().unwrap_or(-1)\n        );\n    }\n}\n\nfn capture_index_stats(binary: &Path, project_root: &Path) -> Result<String> {\n    println!(\"Fetching Codanna index metadata...\");\n    let output = Command::new(binary)\n        .arg(\"mcp\")\n        .arg(\"get_index_info\")\n        .arg(\"--json\")\n        .current_dir(project_root)\n        .output()\n        .with_context(|| \"failed to run 'codanna mcp get_index_info --json'\")?;\n\n    if !output.status.success() {\n        let stderr = String::from_utf8_lossy(&output.stderr);","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/indexer.rs#L66-L102","documentation":"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.","triggerScenarios":"Running the indexer when `codanna index` fails inside the project, e.g. unindexable source tree, codanna internal error, or missing index configuration after init.","commonSituations":"Source directory contains files codanna cannot parse; codanna was never initialized for the project; disk/permission errors while writing the index; incompatible codanna version.","solutions":["Run `codanna index` manually in the project root to see the real error output.","Ensure `codanna init` completed successfully for this project before indexing.","Update codanna to the latest version and retry.","Check write permissions on the project directory/index storage location."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure init ran and codanna exists before indexing\nassert!(which::which(\"codanna\").is_ok(), \"codanna missing from PATH\");\nassert!(Path::new(\".codanna\").exists() || Path::new(\"codanna.json\").exists(),\n        \"project not initialized; run codanna init first\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = run_indexer() {\n    let msg = e.to_string();\n    if msg.contains(\"'codanna index' exited\") {\n        eprintln!(\"indexing failed; run `codanna index` manually for details: {msg}\");\n    } else {\n        return Err(e.into());\n    }\n}","preventionTips":["Always run init before index","Check disk space and write permissions in the project directory","Run `codanna index` manually after tool upgrades to catch incompatibilities early"],"tags":["subprocess","external-tool","exit-code","indexing"],"backgroundTag":"nonzero-exit-code","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}