apply_patch fails with No such file or directory on existing files in codex-cli 0.118.0
What version of Codex CLI is running?
codex-cli 0.118.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.4
What platform is your computer?
Linux 6.12.75+rpt-rpi-2712 aarch64 unknown
What terminal emulator and version are you using (if applicable)?
LXTerminal 0,4,1
What issue are you seeing?
Environment:
- codex-cli 0.118.0
- Linux
- observed on April 4, 2026
Problem:
- apply_patch fails with:
execution error: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })
Verified:
- Reproduces on a real project file and on a trivial new file.
- Reproduces with both absolute and relative target paths.
- The target files exist at patch time.
- /usr/bin/patch is installed and working locally (GNU patch 2.8).
Environment:
- codex-cli 0.118.0
- Linux
- observed on April 4, 2026
Problem:
- apply_patch fails with:
execution error: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })
Verified:
- Reproduces on a real project file and on a trivial new file.
- Reproduces with both absolute and relative target paths.
- The target files exist at patch time.
- /usr/bin/patch is installed and working locally (GNU patch 2.8).
Minimal reproduction:
- Create a test file:
printf 'alpha\n' > /root/.codex/memories/apply_patch_probe.txt
- Attempt:
* Begin Patch
* Update File: /root/.codex/memories/apply_patch_probe.txt
@@
-alpha
+beta
*** End Patch
- Result:
execution error: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })
Also reproduced with:
* Begin Patch
* Update File: .codex/memories/apply_patch_probe.txt
@@
-alpha
+gamma
*** End Patch
Expected:
- apply_patch should update the file.
Notes:
- This appears to be a Codex tool/runtime issue rather than a bad patch or missing target file.
- I have observed the same failure across multiple Codex sessions.
Notes:
- This appears to be a Codex tool/runtime issue rather than a bad patch or missing target file.
- I have observed the same failure across multiple Codex sessions.
What steps can reproduce the bug?
Minimal reproduction:
- Create a test file:
printf 'alpha\n' > /root/.codex/memories/apply_patch_probe.txt
- Attempt:
* Begin Patch
* Update File: /root/.codex/memories/apply_patch_probe.txt
@@
-alpha
+beta
*** End Patch
- Result:
execution error: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })
Also reproduced with:
* Begin Patch
* Update File: .codex/memories/apply_patch_probe.txt
@@
-alpha
+gamma
*** End Patch
What is the expected behavior?
Expected:
- apply_patch should update the file.
Additional information
Notes:
- This appears to be a Codex tool/runtime issue rather than a bad patch or missing target file.
- I have observed the same failure across multiple Codex sessions.
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Additional verified details from the affected machine:
specifically for testing.
/usr/bin/patchis present and working locally:command -v patch->/usr/bin/patchpatch --version->GNU patch 2.8apply_patchfailure across multiple Codex sessions, not just a singlethread.
If you're able to repro this, please use
/feedbackto upload your logs and session details, then post the thread ID here.I can reproduce this too on a separate Linux environment with
codex-cli 0.118.0.This does not look sporadic in the affected environment. It triggers on the first minimal
apply_patchprobe and then keeps reproducing on every subsequent probe I tried.Additional verified details from this affected session:
apply_patchcall./tmp.*** Add File:into/tmp.Minimal repro from this session:
Observed shell output:
I also reproduced the same error with:
and with:
This looks very similar to the old ENOENT signature from #6643, and broader than a pure session-CWD mismatch because an existing absolute
/tmppath also fails.Inference: the
apply_patchbackend/runtime appears to be resolving a different filesystem namespace/root than the shell session.@vak does the issue go away with a version pre 118?
Additional verified follow-up on this issue after updating to the latest published CLI.
I checked the current CLI bug report template first (
.github/ISSUE_TEMPLATE/3-cli.yml): it says to avoid duplicate issues, make sure the latest version is installed, and include full error text plus thread id if applicable. This comment is a follow-up on the existing issue, not a new report.Environment
codex-cli 0.120.0Linux 6.17.0-14-generic x86_64 unknowngpt-5.4What I verified locally
0.118.0to0.120.0./usr/bin/codex --versionreportscodex-cli 0.120.0.apply_patchcommand still works locally on the same probe files.apply_patchpath still fails in fresh post-update Codex sessions.Fresh-session repro evidence
019d7cea-6173-7d42-aedc-7aa0c2d390ea/root/tmp/codex-fresh-probe/sample.txtapply_patchfailed./root/root/tmp/...019d7ceb-5198-7740-a3c9-29c66ac9dfd6/root/tmp/codex-fresh-probe-rel/sample.txtapply_patchused relative pathtmp/codex-fresh-probe-rel/sample.txtObserved conclusion
0.120.0.0.118.0session problem.0.120.0looks like path resolution is wrong for absolute paths (/root/root/...).apply_patchsucceeds on the same machine/workspace while tool-levelapply_patchfails still points to a tool/runtime path issue rather than a missing target file.If helpful, I can provide more sanitized reproduction details from those session ids.