You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] bash: line 1: applypatch: command not found #2072
The lack of underscores for calling may be a manifestation of reinforcement learning. It is recommended to remove underscores from the source code, as modifying the source code is much easier than modifying the model.
I use this in ~/.codex/AGENTS.md and it works good
**AGENTS Usage Guide — About `apply_patch`**-**Purpose:** Ensure the model uses the correct patch‑tool name when modifying the workspace, avoiding misuse that leads to errors or confusion.
-**Never use:**`applypatch` or `apply-patch` (without the underscore). These commands do not exist in the system and will result in “command not found” errors.
-**Correct usage (must include the underscore):**`apply_patch`.
-**Recommended examples (patch‑call examples for the model’s reference):**1.**Patch format to modify a file**``` *** Begin Patch *** Update File: path/to/file.txt @@ -old line +new line *** End Patch ``` 2. **Calling it from the shell (handled by the execution environment)** ```json shell {"command":["apply_patch","*** Begin Patch\n*** Update File: path/to/file.txt\n@@\n-old line\n+new line\n*** End Patch\n"]} ```- **Note:** Always write the underscore (`_`) explicitly. If you encounter `applypatch` or `apply-patch`, replace it with `apply_patch`.- **Why this matters:** Using the correct name guarantees that the patch is applied properly and prevents unnecessary execution errors.
I use this in ~/.codex/AGENTS.md and it works good
AGENTS Usage Guide — About apply_patch
Purpose: Ensure the model uses the correct patch‑tool name when modifying the workspace, avoiding misuse that leads to errors or confusion.
Never use:applypatch or apply-patch (without the underscore). These commands do not exist in the system and will result in “command not found” errors.
Correct usage (must include the underscore):apply_patch.
Recommended examples (patch‑call examples for the model’s reference):
Patch format to modify a file
*** Begin Patch
*** Update File: path/to/file.txt
@@
-old line
+new line
*** End Patch
Calling it from the shell (handled by the execution environment)
shell {"command":["apply_patch","*** Begin Patch\n*** Update File: path/to/file.txt\n@@\n-old line\n+new line\n*** End Patch\n"]}
Note: Always write the underscore (_) explicitly. If you encounter applypatch or apply-patch, replace it with apply_patch.
Why this matters: Using the correct name guarantees that the patch is applied properly and prevents unnecessary execution errors.
I was writing a reply about this exact solution when your latest message appeared. I can confirm that this solution works great, at least as a temporary measure. It also significantly reduces the number of wasted API calls and tokens.
This still seems to be not fully resolved. I just installed latest codex CLI, all default settings, using API key, WSL2/Arch. I got this error while codex was trying to edit a Swift file. Happy to provide more info if needed.
Activity
vitatea2023 commentedon Aug 9, 2025
@bolinfest
vitatea2023 commentedon Aug 9, 2025
The lack of underscores for calling may be a manifestation of reinforcement learning. It is recommended to remove underscores from the source code, as modifying the source code is much easier than modifying the model.
vitatea2023 commentedon Aug 9, 2025
@easong-openai
vitatea2023 commentedon Aug 10, 2025
I use this in
~/.codex/AGENTS.mdand it works goodliarco commentedon Aug 10, 2025
I was writing a reply about this exact solution when your latest message appeared. I can confirm that this solution works great, at least as a temporary measure. It also significantly reduces the number of wasted API calls and tokens.
vitatea2023 commentedon Aug 11, 2025
@dylan-hurd-oai @gpeal
vitatea2023 commentedon Aug 11, 2025
@ae-openai
vitatea2023 commentedon Aug 11, 2025
@pakrym-oai
dylan-hurd-oai commentedon Aug 14, 2025
Please refrain from tagging contributors - we do monitor this! This should be resolved by #2186
[apply-patch] Fix applypatch for heredocs (#2477)
[apply-patch] Fix applypatch for heredocs (openai#2477)
[apply-patch] Fix applypatch for heredocs (openai#2477)
frixaco commentedon Oct 2, 2025
This still seems to be not fully resolved. I just installed latest codex CLI, all default settings, using API key, WSL2/Arch. I got this error while codex was trying to edit a Swift file. Happy to provide more info if needed.
monneyboi commentedon Oct 18, 2025
I just ran into this as well. On Arch linux, using openai API key with
codex-cli 0.19.0bolinfest commentedon Oct 19, 2025
@monneyboi The current version of Codex is
0.47.0: please upgrade![apply-patch] Fix applypatch for heredocs (openai#2477)