codex - 💡(How to fix) Fix macOS: internal apply_patch intermittently times out on simple edits [1 comments, 1 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#17834Fetched 2026-04-15 06:27:24
View on GitHub
Comments
1
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×3commented ×1unlabeled ×1

On macOS ARM64 with codex-cli 0.120.0, the internal apply_patch tool intermittently hangs for about 10 seconds and returns exit code 124 on simple file edits. The same patch often succeeds on a later retry. In one repro, adding *** End of File to the patch made the retry succeed immediately.

This does not appear to be an installation problem:

  • codex --version reports codex-cli 0.120.0
  • the native binary is present via the normal npm-installed wrapper
  • there is no standalone apply_patch executable on PATH, which appears to be expected because apply_patch is an internal tool

Error Message

  • fail quickly with a deterministic parse/verification error

Root Cause

  • codex --version reports codex-cli 0.120.0
  • the native binary is present via the normal npm-installed wrapper
  • there is no standalone apply_patch executable on PATH, which appears to be expected because apply_patch is an internal tool

Fix Action

Fix / Workaround

On macOS ARM64 with codex-cli 0.120.0, the internal apply_patch tool intermittently hangs for about 10 seconds and returns exit code 124 on simple file edits. The same patch often succeeds on a later retry. In one repro, adding *** End of File to the patch made the retry succeed immediately.

  • codex --version reports codex-cli 0.120.0
  • the native binary is present via the normal npm-installed wrapper
  • there is no standalone apply_patch executable on PATH, which appears to be expected because apply_patch is an internal tool
tmpdir=$(mktemp -d /tmp/codex-applypatch2.XXXXXX)
printf 'one\ntwo\n' > "$tmpdir/sample.txt"

Code Example

tmpdir=$(mktemp -d /tmp/codex-applypatch2.XXXXXX)
printf 'one\ntwo\n' > "$tmpdir/sample.txt"

---

codex exec --json --full-auto --skip-git-repo-check --cd "$tmpdir" \
  'Edit sample.txt to replace two with two patched, using apply_patch if available.'

---

*** Begin Patch
*** Update File: sample.txt
@@
-two
+two patched
*** End Patch

---

command timed out after 10010 milliseconds

---

{"exit_code":124,"duration_seconds":10.0}

---

*** Begin Patch
*** Update File: sample.txt
@@
-two
+two patched
*** End of File
*** End Patch
RAW_BUFFERClick to expand / collapse

Summary

On macOS ARM64 with codex-cli 0.120.0, the internal apply_patch tool intermittently hangs for about 10 seconds and returns exit code 124 on simple file edits. The same patch often succeeds on a later retry. In one repro, adding *** End of File to the patch made the retry succeed immediately.

This does not appear to be an installation problem:

  • codex --version reports codex-cli 0.120.0
  • the native binary is present via the normal npm-installed wrapper
  • there is no standalone apply_patch executable on PATH, which appears to be expected because apply_patch is an internal tool

Environment

  • Host: Mac mini
  • OS: Darwin 25.3.0 / macOS ARM64
  • Codex CLI: 0.120.0
  • Install path: /opt/homebrew/bin/codex
  • Wrapper target: /opt/homebrew/lib/node_modules/@openai/codex/bin/codex.js
  • Native package: @openai/codex-darwin-arm64

Repro

Create a scratch file:

tmpdir=$(mktemp -d /tmp/codex-applypatch2.XXXXXX)
printf 'one\ntwo\n' > "$tmpdir/sample.txt"

Run Codex in writable exec mode:

codex exec --json --full-auto --skip-git-repo-check --cd "$tmpdir" \
  'Edit sample.txt to replace two with two patched, using apply_patch if available.'

What happened in the recorded session:

  1. Codex read sample.txt correctly.
  2. Codex invoked internal apply_patch with:
*** Begin Patch
*** Update File: sample.txt
@@
-two
+two patched
*** End Patch
  1. The tool returned:
command timed out after 10010 milliseconds

with metadata:

{"exit_code":124,"duration_seconds":10.0}
  1. The file was unchanged after the timeout.
  2. A retry with the same minimal patch also timed out.
  3. A later retry with:
*** Begin Patch
*** Update File: sample.txt
@@
-two
+two patched
*** End of File
*** End Patch

then succeeded immediately.

Observed Behavior

  • First apply_patch attempt often times out after ~10 seconds.
  • The target file remains unchanged after the timeout.
  • A later retry may succeed.
  • In at least one repro, adding *** End of File changed the outcome from timeout to success.
  • Enabling apply_patch_freeform did not eliminate the first-attempt timeout in my testing.

Expected Behavior

The minimal patch should either:

  • apply successfully on the first attempt, or
  • fail quickly with a deterministic parse/verification error

It should not hang for ~10 seconds on a tiny local file.

Notes

  • This was reproducible outside the local harness sandbox, so it does not appear to be caused by the harness blocking writes.
  • I also found the same command timed out after 10010 milliseconds pattern in earlier interactive Codex logs, so this does not look specific to codex exec.

If useful, I can provide the exact JSONL session log excerpt and the matching codex-tui.log lines.

extent analysis

TL;DR

The issue can be potentially resolved by modifying the patch to include *** End of File before *** End Patch, as this change has been observed to immediately succeed in at least one repro.

Guidance

  • Verify that the issue is not specific to the codex exec mode by testing the apply_patch tool directly with the minimal patch.
  • Test patches with and without *** End of File to confirm if this consistently resolves the timeout issue.
  • Investigate the apply_patch tool's behavior on small files to determine if there's a specific condition causing the 10-second timeout.
  • Consider providing the exact JSONL session log excerpt and the matching codex-tui.log lines for further analysis.

Example

No code snippet is provided as the issue seems to be related to the specific behavior of the apply_patch tool and the format of the patch files.

Notes

The root cause of the issue is still uncertain, and further investigation is needed to determine why adding *** End of File resolves the timeout. The provided information suggests that this might be related to how the apply_patch tool handles patch files.

Recommendation

Apply workaround: Modify the patch to include *** End of File before *** End Patch, as this has been observed to immediately succeed in at least one repro. This recommendation is based on the observation that adding *** End of File changed the outcome from timeout to success in the provided repro.

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