openai/codex · error · anyhow::Error

missing program name

Error message

missing program name

What it means

Error "missing program name" thrown in openai/codex.

Source

Thrown at codex-rs/utils/pty/src/win/psuedocon.rs:264

    for (key, value) in cmd.iter_full_env_as_str() {
        block.extend(OsStr::new(key).encode_wide());
        block.push(b'=' as u16);
        block.extend(OsStr::new(value).encode_wide());
        block.push(0);
    }
    block.push(0);
    block
}

fn build_cmdline(cmd: &CommandBuilder) -> anyhow::Result<(Vec<u16>, Vec<u16>)> {
    let exe_os: OsString = if cmd.is_default_prog() {
        cmd.get_env("ComSpec")
            .unwrap_or(OsStr::new("cmd.exe"))
            .to_os_string()
    } else {
        let argv = cmd.get_argv();
        let Some(first) = argv.first() else {
            anyhow::bail!("missing program name");
        };
        search_path(cmd, first)
    };

    let mut cmdline = Vec::new();
    append_quoted(&exe_os, &mut cmdline);
    for arg in cmd.get_argv().iter().skip(1) {
        cmdline.push(' ' as u16);
        ensure!(
            !arg.encode_wide().any(|c| c == 0),
            "invalid encoding for command line argument {arg:?}"
        );
        append_quoted(arg, &mut cmdline);
    }
    cmdline.push(0);

    let mut exe: Vec<u16> = exe_os.encode_wide().collect();
    exe.push(0);

View on GitHub (pinned to 339751715c)

When it happens

Trigger: Thrown at codex-rs/utils/pty/src/win/psuedocon.rs:264 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/22f4fdaf6fbdd4e4. Report an issue: GitHub.