nikivdev/code · error

external codex browser exited unsuccessfully with status {}

Error message

external codex browser exited unsuccessfully with status {}

What it means

When the external codex browser helper (launched from its manifest via a tool descriptor) finishes with a non-zero exit status, the browse flow in src/ai.rs:5418 bails with this message embedding the status code. The selection file it was supposed to write cannot be trusted, so the browse operation fails loudly instead of returning a bogus session selection.

Source

Thrown at src/ai.rs:5418

    )?;
    command
        .stdin(Stdio::inherit())
        .stdout(Stdio::inherit())
        .stderr(Stdio::inherit())
        .env(
            "CODEX_SESSION_BROWSER_CODEX_BIN",
            configured_codex_bin_for_workdir(&target),
        );

    let status = command.status().with_context(|| {
        format!(
            "failed to launch external codex browser from {}",
            tool.manifest_path.display()
        )
    })?;

    if !status.success() {
        bail!(
            "external codex browser exited unsuccessfully with status {}",
            status
        );
    }

    let selected_id = fs::read_to_string(selection_file.path())
        .with_context(|| "failed to read codex browser selection file")?;
    let selected_id = selected_id.trim();
    if selected_id.is_empty() {
        return Ok(());
    }

    resume_session(
        Some(selected_id.to_string()),
        Some(target.display().to_string()),
        Provider::Codex,
    )
}

View on GitHub (pinned to a747e741ae)

Solutions

  1. Re-run `f ai codex browse` — transient aborts/crashes often succeed on retry
  2. Verify the external browser tool and its manifest_path are intact and executable
  3. Run the external browser directly to see its real error output and fix the underlying cause
  4. Check exit status shown: non-zero codes from user cancellation may simply mean pick a session without cancelling

Example fix

// before: manifest points at a missing script
{"bin": "./target/debug/missing-browser"}
// after: rebuilt/valid manifest path
{"bin": "./target/release/codex-browser"}
Defensive patterns

Strategy: retry

Validate before calling

let manifest = PathBuf::from(&manifest_path);
if !manifest.exists() {
    eprintln!("External codex browser manifest missing at {}", manifest.display());
    return;
}

Type guard

fn browser_ready(manifest_path: &Path) -> bool {
    manifest_path.exists()
}

Try / catch

match browse_codex_sessions(path, query, Provider::Codex) {
    Err(e) if e.to_string().contains("exited unsuccessfully with status") => {
        eprintln!("{e} — retrying once; if it persists, run the browser tool directly to see its stderr");
        // retry or inspect the external tool
    }
    other => other?,
}

Prevention

When it happens

Trigger: The spawned external browser process returns a non-success exit status — browser crashed, user aborted the picker with an error exit, missing manifest dependencies, or the tool manifest points to a broken/failed script.

Common situations: External browser tool not built/installed correctly; terminal closed or signal killed the picker; script bug in the external browser causing non-zero exit; disk/permission error writing the selection file inside the browser.

Related errors


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