functions.apply_patch fails with No such file or directory after patch approval even though apply_patch works via shell

Open 💬 2 comments Opened Apr 14, 2026 by Robertohsantos
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

functions.apply_patch is failing consistently in my local Codex environment after patch approval.

Environment:

  • Codex CLI: 0.120.0
  • Install source: global npm package @openai/codex@0.120.0
  • OS: Linux x86_64, WSL2
  • Bubblewrap: 0.9.0

What fails:

  • A normal built-in apply_patch tool call
  • Even a minimal patch that adds a one-line file in /tmp

Minimal repro:
```text
* Begin Patch
* Add File: /tmp/codex-apply-patch-probe.txt
+probe
*** End Patch

Observed behavior:

  • patch approval is requested
  • approval is accepted
  • the tool fails with:

codex_core::exec: exec error: No such file or directory (os error 2)
codex_core::tools::router: error=execution error: Io(Os { code: 2, kind: NotFound, message: "No such file or
directory" })

Relevant log excerpt from ~/.codex/log/codex-tui.log:

2026-04-14T11:11:37.849437Z ... ToolCall: apply_patch * Begin Patch
* Add File: /tmp/codex-apply-patch-probe.txt
+probe
*** End Patch
...
2026-04-14T11:11:39.781642Z ... codex.op="patch_approval"
2026-04-14T11:11:39.785506Z ERROR codex_core::exec: exec error: No such file or directory (os error 2)
2026-04-14T11:11:39.793360Z ERROR codex_core::tools::router: error=execution error: Io(Os { code: 2, kind: NotFound,
message: "No such file or directory" })

Control test:

  • The same apply_patch executable works correctly when invoked directly via shell with the same patch payload.
  • It also works when invoking the vendor binary directly with argv0=apply_patch.

Example shell control:

/home/robertoh/.codex/tmp/arg0/codex-arg0ptO3zX/apply_patch <<EOF
* Begin Patch
* Add File: /tmp/codex-applypatch-shell-probe.txt
+probe
*** End Patch
EOF

That succeeds and creates the file correctly.

Why this seems like a Codex tool-runner issue:

  • the patch parser itself is healthy
  • the apply_patch binary itself is healthy
  • the failure happens specifically in the built-in tool path after patch_approval
  • this reproduced across multiple threads/projects, not just one repo
  • this does not appear to be related to MCP wiring; in the active environment codex mcp list only showed playwright

and supabase

Current hypothesis:

  • the regression is in the internal runner path around functions.apply_patch / patch_approval / internal exec, not in

the standalone patch binary

Things already ruled out:

  • missing apply_patch symlink
  • broken vendor binary
  • broken shell execution of apply_patch
  • missing common executables like git, patch, bash, sh, env, mktemp

Suggested upstream checks:

  • log the exact program path and argv used after patch_approval
  • check whether the tool path is launching a missing wrapper/helper distinct from the standalone apply_patch binary
  • check whether this is a regression in 0.120.0

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #17517
  • #17240
  • #16970
  • #16791
  • #16102

Powered by Codex Action

mellowmarshall · 4 months ago

Adding another repro from a separate WSL2 environment. This appears to still reproduce on @openai/codex@0.121.0.

Environment:

  • Codex package: @openai/codex 0.121.0
  • Package repository metadata: git+https://github.com/openai/codex.git, directory codex-cli
  • OS: WSL2 Ubuntu
  • Kernel: Linux DESKTOP-GBE5CTF 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 GNU/Linux
  • Working directory: /home/logan/Dev/mrp

Observed from the built-in tool wrapper:

functions.apply_patch
*** Begin Patch
*** Add File: /home/logan/Dev/mrp/.codex_apply_patch_probe
+probe
*** End Patch

fails with:

execution error: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })

The same failure occurs for normal relative-path patches in the repo. It has reproduced repeatedly over multiple sessions.

Important contrast: the shell apply_patch CLI works from the same repo root.

$ command -v apply_patch
/home/logan/.codex/tmp/arg0/codex-arg0zba9D5/apply_patch

$ ls -l "$(command -v apply_patch)"
/home/logan/.codex/tmp/arg0/codex-arg0zba9D5/apply_patch -> /home/logan/.npm-global/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex/codex

$ apply_patch <<'PATCH'
*** Begin Patch
*** Add File: .codex_apply_patch_cli_probe
+probe
*** End Patch
PATCH
Success. Updated the following files:
A .codex_apply_patch_cli_probe

So in this environment the underlying CLI path is valid and can patch files; the failure appears isolated to the functions.apply_patch tool-wrapper/integration path rather than the patch grammar or repository filesystem.