{"record":{"id":"f6f54a7fa1abd0a6","repo":"nikivdev/code","slug":"codanna-init-exited-with-status","errorCode":null,"errorMessage":"'codanna init' exited with status {}","messagePattern":"'codanna init' exited with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/indexer.rs","lineNumber":64,"sourceCode":"    let settings = project_root.join(\".codanna/settings.toml\");\n    if settings.exists() {\n        return Ok(());\n    }\n\n    println!(\n        \"No Codanna settings found at {} – running 'codanna init'.\",\n        settings.display()\n    );\n    let status = Command::new(binary)\n        .arg(\"init\")\n        .current_dir(project_root)\n        .status()\n        .with_context(|| \"failed to spawn 'codanna init'\")?;\n\n    if status.success() {\n        Ok(())\n    } else {\n        bail!(\n            \"'codanna init' exited with status {}\",\n            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(())","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/indexer.rs#L46-L82","documentation":"ensure_codanna_initialized spawns the external `codanna init` command as a subprocess. If the process exits with a non-zero status (after successfully spawning), the tool wraps that exit code into this anyhow error. It indicates codanna's own initialization step failed, not a spawn failure.","triggerScenarios":"Running the indexer's run() flow when `codanna init` is not properly installed/configured, has a broken config, or otherwise returns a non-zero exit code.","commonSituations":"codanna is installed but its config file is invalid; a PATH-resolved `codanna` shim is an old incompatible version; codanna init fails due to permissions in the target directory.","solutions":["Run `codanna init` manually in the project root and read its stderr output to see the underlying failure.","Check `codanna --version` and upgrade/reinstall codanna if it is outdated or broken.","Fix any codanna configuration issues (invalid config file, missing permissions) reported by manual init.","Verify the `codanna` binary resolved on PATH is the intended one (`which codanna`)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if which::which(\"codanna\").is_err() {\n    eprintln!(\"codanna not found on PATH; install it first\");\n}\nlet ok = std::process::Command::new(\"codanna\")\n    .arg(\"--version\")\n    .status()\n    .map(|s| s.success())\n    .unwrap_or(false);\nif !ok { eprintln!(\"codanna is broken or too old\"); }","typeGuard":null,"tryCatchPattern":"match run_indexer() {\n    Ok(stats) => handle(stats),\n    Err(e) if e.to_string().contains(\"'codanna init' exited\") => {\n        eprintln!(\"codanna init failed; run `codanna init` manually to see stderr\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Install and verify codanna (`codanna --version`) before running the indexer","Run `codanna init` once manually per project and commit the resulting config","Keep codanna up to date to avoid subcommand/behavior drift"],"tags":["subprocess","external-tool","exit-code"],"backgroundTag":"nonzero-exit-code","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}