Skip to content

[BUG] bash: line 1: applypatch: command not found #2072

Closed

Description

@vitatea2023

What version of Codex is running?

codex-cli 0.20.0

Which model were you using?

gpt-5

What platform is your computer?

Linux 6.14.9-arch1-1 x86_64 unknown

What steps can reproduce the bug?

It is common to use GPT-5 programming in daily life

What is the expected behavior?

Normal implementation of replacing text

What do you see instead?

Image

Additional information

No response

Activity

  1. added
    bug
    on Aug 9, 2025
  2. vitatea2023 commented on Aug 9, 2025

    @vitatea2023
    Author
  3. vitatea2023 commented on Aug 9, 2025

    @vitatea2023
    Author

    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.

  4. vitatea2023 commented on Aug 9, 2025

    @vitatea2023
    Author
  5. vitatea2023 commented on Aug 10, 2025

    @vitatea2023
    Author

    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.
    
  6. liarco commented on Aug 10, 2025

    @liarco

    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)

        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.

  7. vitatea2023 commented on Aug 11, 2025

    @vitatea2023
    Author
  8. vitatea2023 commented on Aug 11, 2025

    @vitatea2023
    Author
  9. vitatea2023 commented on Aug 11, 2025

    @vitatea2023
    Author
  10. dylan-hurd-oai commented on Aug 14, 2025

    @dylan-hurd-oai
    Contributor

    Please refrain from tagging contributors - we do monitor this! This should be resolved by #2186

  11. frixaco commented on Oct 2, 2025

    @frixaco

    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.

  12. monneyboi commented on Oct 18, 2025

    @monneyboi

    I just ran into this as well. On Arch linux, using openai API key with codex-cli 0.19.0

  13. bolinfest commented on Oct 19, 2025

    @bolinfest
    Collaborator

    @monneyboi The current version of Codex is 0.47.0: please upgrade!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions