Skip to content

VS CODE Codex extension : Apply_patch is failing #14744

Open

Description

@Kingwolf123

What version of the IDE extension are you using?

The latest version

What subscription do you have?

Plus

Which IDE are you using?

VS Code

What platform is your computer?

Windows 11 64Bit Latest

What issue are you seeing?

#13574

Same issue as this. Codex is failing apparently to do writes or updates on files.
Please fix.

What steps can reproduce the bug?

Just edit or ask codex to change files / code in VS code extension

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    extension
    on Mar 15, 2026
  2. added
    bug
    tool-calls
    windows-os
    on Mar 15, 2026
  3. github-actions commented on Mar 15, 2026

    @github-actions
    Contributor
  4. etraut-openai commented on Mar 15, 2026

    @etraut-openai
    Contributor

    Please provide the version number of the app that you have installed.

  5. Kingwolf123 commented on Mar 15, 2026

    @Kingwolf123
    Author

    Please provide the version number of the app that you have installed.

    VS CODE: 1.111.0
    Codex extension for VS CODE : 26.311.21342

  6. Norway174 commented on Mar 15, 2026

    @Norway174

    Can confirm, I have the same issue as well.

    VSCode: 1.111.0
    Codex extension: 26.5311.21342

    The error code the AI tells me it's getting when I ask why the edits are rejected;
    windows sandbox: setup refresh failed with status exit code: 1

    It seems to be able to edit files in the root of my project. But fails on any sub-folders.

    If I change the Permissions from Default Permissions to Full Access, the it works without errors. Though, I'd rather not give the AI access to my whole system.

  7. pzarzycki commented on Mar 16, 2026

    @pzarzycki

    Codex CLI and Codex Windows app suffers the same way. apply_patch is failing in Default sandbox for some files (often in /src/**). Forces to allow codex full permission.

    codex --version
    codex-cli 0.114.0
  8. Shen commented on Mar 17, 2026

    @Shen

    Also the same problem:
    Codex extension: 26.5313.41514
    VSCode: 1.111.0

  9. Wangningsen commented on Mar 17, 2026

    @Wangningsen

    My codex extension 26.313.41514 is also still having this bug

  10. jvvilar commented on Mar 20, 2026

    @jvvilar

    Codex is borderline unusable on Windows because of the patch tool issue. Wastes loads of tokens trying the tool and going on direct file edits, then failing those edits and trying again.

    It's slow, it's wasteful and just a broken product. The customers paying for the most tokens on your most expensive models should probably have this fixed in a timely manner.

  11. GitMurf commented on Mar 20, 2026

    @GitMurf

    @jvvilar et al, I agree! For what its worth, the only "workaround" / fix for now is using the Codex CLI directly and rolling back to v0.113. See my comment here in another similar gh issue: #14675 (comment)

    Can't use the Codex App for the VScode extension, but can at least use the Codex CLI directly for now.

  12. jvvilar commented on Mar 20, 2026

    @jvvilar

    Can confirm that @GitMurf 's suggestion works. Installed codex v0.113.0 and the patch tool works perfectly in VScode's integrated terminal. Thanks for the tip.

  13. GitMurf commented on Mar 20, 2026

    @GitMurf

    @jvvilar I was able to get a little further in debugging the issue. Here is a workaround that should work with current version of Codex: #14675 (comment)

  14. Kingwolf123 commented on Mar 27, 2026

    @Kingwolf123
    Author

    Has this been fixed?
    How can codex windows be left without this unpatched / fixed?

    This issue makes it practically unusable because i , along with majority of people dont want to risk giving full unabated access to all my PC . Without full access, codex is practically useless for any actual work in VS Code or even using Codex app, for which i believe this bug is also present, and i find that working with it has been untenable

    This needs to be fixed ASAP.

  15. pzarzycki commented on Mar 28, 2026

    @pzarzycki

    Codex sandbox on Windows works terribly. It forces the user to turn on dangerous full permissions often.

    Example: I have gh command authenticated. Codex from sandbox is unable to run it, doesn't request user permissions, even in "auto-guardian" mode.

    At the same time messes with user permissions on the NTFS. There are files in .git/ and node_modules/ I don't have permission to. Forces to run administrative cleanup, etc.

    Really frustrating.

  16. GitMurf commented on Mar 28, 2026

    @GitMurf

    Example: I have gh command authenticated. Codex from sandbox is unable to run it, doesn't request user permissions, even in "auto-guardian" mode.

    Agree... but what I have found is gh (and most other tools that have issues) will work if you tell Codex whenever there is a CLI tool / permission issue to try running using the elevated permissions "tool". I have it in my agents md and it has actually been fairly reliable to follow it. Then when it runs gh for example it is authenticated as my user and works fine.

    Very annoying though. And my latest frustration is trying to use worktrees in Codex App because it has git issues and has to add each worktree folder to git config (and they use uuids so has to happen with every worktree).

  17. franzbischoff commented on Aug 17, 2026

    @franzbischoff

    I had this problem on my Linux, and Codex helped me solve it.

    First, diagnose the problem

    First, test if this resolves the problem temporarily:

    sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
    codex sandbox linux /bin/true
    sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=1

    If the codex command runs, this is your problem. (If the Codex is not found, ask the chat itself to run the command, and it will figure out the path.

    Then fix the problem

    Create an AppArmor rule for Codex:

    sudoedit /etc/apparmor.d/codex-bwrap

    paste (change the YOURUSERNAME to your user name, of course):

    abi <abi/4.0>,
    include <tunables/global>
    
    profile codex-bwrap /home/YOURUSENAME/.vscode-server/extensions/openai.chatgpt-*-linux-x64/bin/linux-x86_64/codex-resources/bwrap flags=(unconfined) {
      userns,
    
      include if exists <local/codex-bwrap>
    }
    

    Validate the syntax

    sudo apparmor_parser -Q /etc/apparmor.d/codex-bwrap

    If no error, load the policy:

    sudo apparmor_parser -r /etc/apparmor.d/codex-bwrap

    Confirm:

    sudo aa-status | grep codex-bwrap

    Reactivate the AppArmor if you had it disabled:

    sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=1

    Try again and see if Codex runs (or try in the IDE):

    /home/YOURUSERNAME/.vscode-server/extensions/openai.chatgpt-CURRENTVERSION-linux-x64/bin/linux-x86_64/codex sandbox /bin/true
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

    bugextensiontool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions