codex - ๐Ÿ’ก(How to fix) Fix functions.apply_patch fails with No such file or directory after patch approval even though apply_patch works via shell [1 comments, 2 participants]

Official PRs (โ€ฆ)
ON THIS PAGE

Recommended Tools

ร—6

Utilities matched from this issueโ€™s tags and category โ€” try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful ยท Quick feedback

Loadingโ€ฆ
GitHub stats
openai/codex#17778โ€ขFetched 2026-04-15 06:28:29
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ร—4commented ร—1unlabeled ร—1

Error Message

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 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,

Fix Action

Fix / Workaround

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

What fails:

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

Minimal repro:

*** Begin Patch
*** Add File: /tmp/codex-apply-patch-probe.txt
+probe
*** End Patch
RAW_BUFFERClick to expand / collapse

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/[email protected]
  • 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:

*** 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

extent analysis

TL;DR

The issue is likely due to a problem in the internal runner path of the Codex tool, specifically around functions.apply_patch and patch_approval, which can be investigated by logging the exact program path and argv used after patch approval.

Guidance

  • Verify that the apply_patch binary is being executed correctly by checking the log files for the exact program path and argv used after patch_approval.
  • Investigate if the tool path is launching a missing wrapper/helper distinct from the standalone apply_patch binary, which could be causing the error.
  • Check if this issue is a regression in version 0.120.0 by testing with previous versions of the Codex CLI.
  • Consider adding logging or debugging statements to the functions.apply_patch code to gain more insight into the execution flow and identify the root cause of the error.

Example

No code snippet is provided as the issue is more related to the execution flow and logging rather than a specific code block.

Notes

The issue seems to be specific to the internal runner path of the Codex tool and not related to the standalone apply_patch binary or other external factors. The fact that the same apply_patch executable works correctly when invoked directly via shell suggests that the issue lies in the tool's internal execution flow.

Recommendation

Apply a workaround by logging the exact program path and argv used after patch_approval to gain more insight into the execution flow and identify the root cause of the error. This will help in understanding if the issue is indeed related to the internal runner path or if it's a regression in version 0.120.0.

Vote matrix ยท Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loadingโ€ฆ

Still need to ship something?

ร—6

Another batch ranked right after the header list โ€” different links, same matching logic.

Back to top recommendations

TRENDING

codex - ๐Ÿ’ก(How to fix) Fix functions.apply_patch fails with No such file or directory after patch approval even though apply_patch works via shell [1 comments, 2 participants]