Skip to content

execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" }) #12089

Closed

Description

@geocine

What version of Codex CLI is running?

codex-cli 0.103.0

What subscription do you have?

plus

Which model were you using?

gpt-5.3-codex

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

Windows Terminal Git Bash

What issue are you seeing?

When running Codex CLI inside Git Bash, any command execution fails before the command is actually run. The CLI appears to attempt execution, but immediately returns:

• Permissions updated to Full Access


› help me analyze the code on this repo


• I’ll do a quick repo reconnaissance first, then map the architecture, key modules, and likely risk areas so you get a
  practical code analysis. I’m starting by listing the project structure and core config files.

• Running Get-ChildItem -Force | Select-Object Name,Mode,Length,LastWriteTime

• Ran rg --files
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

• Ran git status --short
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

• The first command batch failed due command invocation formatting, so I’m retrying with direct shell calls one by one
  to get the file inventory.

• Ran pwd
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

• Ran Get-Location
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

• Ran ls
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

• Ran ls
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

• Ran C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Get-Location"
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

• I’m still blocked by a shell runner error before any command executes. I’ll try one last compatibility fallback (cmd /
  c dir) to confirm whether command execution is generally unavailable.

• Ran cmd /c dir
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

• Searched

• Ran echo hi
  └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

What steps can reproduce the bug?

  1. Open Windows Terminal.
  2. Use the Git Bash profile.
  3. Run codex.
  4. Enter a prompt that triggers repository inspection (e.g., “help me analyze the code on this repo”).
  5. Codex attempts to execute shell commands.
  6. All commands fail with:
Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

What is the expected behavior?

Commands should execute normally (as they did in codex-cli 0.101.0) regardless of whether the shell is:

  • Git Bash
  • CMD
  • PowerShell

This worked correctly in codex-cli 0.101.0 under Git Bash.

Additional information

In Git Bash only:

  • All shell commands fail immediately.
  • Even trivial commands like echo hi fail.
  • The failure occurs before command execution.
  • The CLI works correctly in CMD.

Activity

  1. added
    bug
    on Feb 18, 2026
  2. added
    CLI
    windows-os
    tool-calls
    on Feb 18, 2026
  3. removed
    CLI
    on Feb 18, 2026
  4. etraut-openai commented on Feb 18, 2026

    @etraut-openai
    Contributor

    Thanks for the bug report. I suspect this is related to a recent update to rg in this PR.

  5. geocine commented on Feb 18, 2026

    @geocine
    Author

    seems like all commands are failing though

    • Permissions updated to Full Access
    
    
    › help me analyze the code on this repo
    
    
    • I’ll do a quick repo reconnaissance first, then map the architecture, key modules, and likely risk areas so you get a
      practical code analysis. I’m starting by listing the project structure and core config files.
    
    • Running Get-ChildItem -Force | Select-Object Name,Mode,Length,LastWriteTime
    
    • Ran rg --files
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    
    • Ran git status --short
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    
    • The first command batch failed due command invocation formatting, so I’m retrying with direct shell calls one by one
      to get the file inventory.
    
    • Ran pwd
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    
    • Ran Get-Location
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    
    • Ran ls
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    
    • Ran ls
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    
    • Ran C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Get-Location"
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    
    ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    
    • I’m still blocked by a shell runner error before any command executes. I’ll try one last compatibility fallback (cmd /
      c dir) to confirm whether command execution is generally unavailable.
    
    • Ran cmd /c dir
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    
    • Searched
    
    • Ran echo hi
      └ execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
  6. etraut-openai commented on Feb 18, 2026

    @etraut-openai
    Contributor

    If you're able to repro this, please use the /feedback command to upload your logs and session details, then post the thread ID here.

    Can you confirm that if you downgrade to 0.101.0, the problem goes away? That will help narrow down the possible causes.

  7. geocine commented on Feb 18, 2026

    @geocine
    Author

    I submitted this using /feedback; the thread ID is 019c6f8e-e006-7d63-beb4-2a9de62a3802.

    For some reason, after downgrading to 0.101.0, the same issue still occurs. I ran npm install -g @openai/[email protected]. It was definitely working prior to the upgrade.

    The error I’m encountering is:

    Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })

    Any clues on how to debug this would be greatly appreciated, as I’m trying to figure out what's going on.

    For now, I'll remove 0.101.0 from the description since it's puzzling that I can't get it working anymore. I am using Codex CLI on the daily on Windows Terminal + Git bash

  8. geocine commented on Feb 18, 2026

    @geocine
    Author

    I have investigated this end to end (with codex help) and confirmed that the error was happening. However, it originated from an interaction between Codex and my local shell hardening setup.

    Error:

    Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })
    

    Root cause:

    • Codex resolves pwsh from the system PATH.

    • On my machine, this may resolve to C:\Users\Aivan\.local\bin\pwsh.cmd (a custom wrapper I created), instead of directly invoking pwsh.exe.

    • This wrapper is intentional: it inspects incoming arguments and blocks -NoProfile so that my PowerShell profile safety guardrails remain active.

    • This acts as a defensive control against risky automated shell usage (including Codex-driven commands), and then forwards allowed arguments to:

      C:\Program Files\PowerShell\7\pwsh.exe
      

    Why this specific error occurred:

    • When powershell_utf8 is enabled, Codex prepends a UTF-8 prefix that includes a newline.

    • Rust rejects newline-containing arguments when the target is a batch file (.cmd), which results in:

      "batch file arguments are invalid"
      

    So this was a compatibility edge case between Codex behavior and my local wrapper policy , not purely a fault of either side.

    Fix / Mitigation:

    • Immediate workaround:

      [features]
      powershell_utf8 = false
      
    • Environment-side alternative:
      Ensure pwsh resolves directly to pwsh.exe, or de-prioritize/remove the custom pwsh.cmd wrapper from PATH resolution during Codex runs.
      However, I do not intend to take this approach. The wrapper and guardrails are intentional, as I have previously experienced Codex executing destructive commands (including wiping my entire drive). The hardening layer is therefore a deliberate safety control.

    Why it may reappear after upgrades or configuration changes:

    • On Windows, powershell_utf8 is enabled by default unless explicitly overridden.
    • If the explicit powershell_utf8 = false override is removed during a configuration reset, profile migration, upgrade, or if the configuration file was deleted at some point, the issue can resurface.

    Since this behavior stems from a custom local setup, we can consider this issue closed unless there is interest in addressing it from another angle (for example, improving compatibility handling between Codex and batch wrappers).

  9. changed the title [-]execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" }) - Windows Terminal Git Bash support broken on 0.103.0[/-] [+]execution error: Io(Error { kind: InvalidInput, message: "batch file arguments are invalid" })[/+] on Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions