Skip to content

Windows: apply_patch fails inside an explicitly writable local project, but works in the visualizations directory #54947

Open

Description

@RagnarHeavyDk

What version of the Codex App are you using (From “About Codex” dialog)?

Desktop app version not verified. Bundled Codex CLI version: 0.163.0-alpha.10.2

What subscription do you have?

Plus

What platform is your computer?

Windows, OS build 26200, native PowerShell environment.

What issue are you seeing?

Summary

The desktop application's local Codex agent cannot create or update files inside an explicitly writable project under Documents. Reading the same project works.

The same apply_patch tool successfully created, read back, and deleted a harmless diagnostic file in the session's permitted visualizations directory. The failure therefore appears path/access-context dependent, rather than a complete failure of apply_patch.

Observed on 18 October 2026, Europe/Madrid.

Environment

  • Desktop UI labelled ChatGPT, using the local Codex backend.
  • Bundled executable reports: codex-cli 0.163.0-alpha.10.2.
  • Desktop application version: not independently verified.
  • Windows OS version reported locally: Microsoft Windows NT 10.0.26200.0.
  • Native PowerShell environment.
  • Workspace-write filesystem sandbox.
  • The target project is explicitly listed among writable roots.
  • Project location, with personal details redacted:
    C:\Users<user>\Documents\Codex<date><project>
  • No Git repository is active in this project.

Expected behaviour

An authorised apply_patch operation should create or update a file inside the writable project, or return a specific actionable explanation for denying the operation.

Actual behaviour

apply_patch repeatedly returns:

“Failed to write file C:\Users<user>\Documents\Codex<date><project>\office<filename>.json”

Attempts to update existing files also failed. Absolute and relative paths were tested.

For the new JSON file, a subsequent filesystem check confirmed that it had not been created. An existing authorisation file's SHA-256 remained unchanged.

Checks and recovery attempts already performed

  1. Reading project files succeeds.
  2. The inspected file was not marked read-only.
  3. Opening and closing a write-access file handle succeeded WITHOUT writing bytes. This does not prove that actual writes succeed.
  4. Scoped write permissions for the specific target files were explicitly granted in one attempt; apply_patch still failed.
  5. Restarting the desktop application did not resolve the problem.
  6. Forking into another chat using the same directory did not resolve it.
  7. Both absolute and relative patch paths failed.
  8. The existing folder was subsequently added through File → Open folder.
  9. The project then appeared in the application's project inventory with the correct directory.
  10. The current chat was associated with that project.
  11. Another turn was started with the project explicitly present in writable roots. apply_patch still failed.
  12. A separate apply_patch probe in the session's permitted .codex\visualizations directory succeeded. Its content was read back, and the temporary probe was deleted successfully. It contained no project data.

Diagnostic comparison

Inside the restricted agent environment, codex doctor reported:

  • Access denied while managing .codex\tmp\arg0-windows aliases/temp directories.
  • Internal SQLite databases could not be opened:
    “(code: 14) unable to open database file”.
  • Connectivity and security-inspection limitations.

These results do NOT establish database corruption. The checks ran inside a restricted environment.

The user separately ran this installed executable in a normal external PowerShell window, without administrator elevation:

codex doctor --summary --ascii --no-color

The reported summary was:

“20 ok | 1 idle | 5 notes | 4 warn | 0 fail degraded”

That external run reported:

  • Sandbox configuration OK.
  • WebSocket connected, HTTP 101.
  • Active provider endpoints reachable.
  • No locally visible recent Codex security enforcement found.
  • Optional MCP configuration warnings remained.

This comparison may help distinguish restrictions affecting diagnostics from a problem in the installation itself. It does not identify the root cause.

Impact and safety

Project edits and progress-record updates are blocked.

No database files were deleted or repaired. No antivirus/security settings were disabled. No installations, financial operations, or project service restarts were performed as a workaround.

The root cause remains unconfirmed. Please investigate the effective filesystem permissions and execution context used by apply_patch for this project, including why the visualizations-directory probe succeeds while the explicitly writable project fails.

What steps can reproduce the bug?

Open an existing local project located under C:\Users\Documents\Codex.

Associate the current chat with that project.

Use workspace-write permissions with the project explicitly included in writable roots.

Ask the local agent to create a small new JSON file inside the project's office directory using apply_patch.

The operation fails with “Failed to write file …”. A subsequent filesystem check confirms that the new file does not exist.

The failure persisted with absolute and relative paths, explicit scoped write approval, an application restart, and a forked chat.

As a comparison, the same apply_patch tool successfully created a harmless test file in the session's permitted .codex\visualizations directory. Its content was read back and the test file was deleted successfully.

What is the expected behavior?

The agent should be able to create or update authorised files inside the explicitly writable local project. If an additional restriction blocks writing, the tool should provide a specific, actionable explanation instead of only “Failed to write file …”.

Additional information

Bundled CLI: codex-cli 0.163.0-alpha.10.2.
Reading project files works. Both creating new files and updating existing files failed.

Inside the restricted agent environment, Codex Doctor reported access-denied warnings for .codex\tmp\arg0-windows and SQLite code 14, “unable to open database file”. These errors do not establish database corruption.

The user ran the installed executable separately in normal PowerShell, without administrator elevation:

codex doctor --summary --ascii --no-color

External result:
20 ok | 1 idle | 5 notes | 4 warn | 0 fail degraded

The external run reported sandbox configuration OK, successful WebSocket and endpoint connectivity, and no locally visible recent Codex security enforcement.

The existing project was successfully added to the application's project inventory and the current chat was associated with it. A subsequent turn still could not write to the project.

No databases were deleted or repaired, no security settings were disabled, and no project services were restarted. The root cause remains unconfirmed.

Activity

  1. added
    app
    on Oct 17, 2026
  2. added
    bug
    windows-os
    sandbox
    tool-calls
    on Oct 17, 2026
  3. JBTradesOA commented on Oct 25, 2026

    @JBTradesOA

    I can reproduce a closely related failure in the Windows Codex desktop app.

    A local project under C:\Users\<redacted>\Documents\Codex\... is explicitly included in the writable workspace roots. Reading files works, but apply_patch repeatedly fails when updating the existing file:

    outputs\market_brief_tool\OA_BASE_BETA_DEVIATION_LOG.md

    The tool reports:

    Failed to write file C:\Users\<redacted>\Documents\Codex\...\outputs\market_brief_tool\OA_BASE_BETA_DEVIATION_LOG.md

    A separate attempt to create a minimal new file in the same project also failed.

    Checks already completed:

    • Target file is not read-only.
    • The Windows account and expected Codex sandbox account have write/modify access.
    • There is ample free disk space.
    • The Codex desktop app was restarted.
    • Default workspace permissions are enabled; Full access is not required for this project path.

    Platform reported by the local environment:
    Microsoft Windows NT 10.0.26300.0 x64

    This blocks project logging and safe isolated test work. Related in-app feedback session ID:
    01a023b8-e406-71f2-a1e2-109593d215b8

  4. baghnon85-boop commented on Oct 25, 2026

    @baghnon85-boop

    Additional sanitized diagnostics from a later reproduction:

    • Codex Desktop: 26.1021.31345 (build 21828).
    • Bundled CLI: codex-cli 0.164.0-alpha.11.1.
    • Windows: 11 Pro, build 26300, x64.
    • Effective sandbox backend reported by codex doctor --json --summary: elevated; provisioning reported complete.
    • Every minimal apply_patch CREATE attempt still fails inside explicitly writable roots with Failed to write file ....
    • CLI startup repeatedly reports:
      • failed to clean up stale arg0 temp dirs: Access is denied. (os error 5)
      • could not create PATH aliases: Access is denied. (os error 5)
    • Redacted affected helper path: %USERPROFILE%\.codex\tmp\arg0-windows\codex-arg0*.
    • Read-only ACL inspection showed the authorized workspace grants the Codex sandbox group Modify, while arg0-windows grants that group only ReadAndExecute, Synchronize.
    • No ACL change was made at any time. A temporary tool-level permission grant did not alter the Windows ACL.
    • Invoking the supported Windows sandbox helper path returned:
      orchestrator_helper_exit_nonzero: setup helper exited with status Some(1).
    • codex doctor also reported SQLite code 14 for internal state databases, but independent read-only immutable PRAGMA quick_check returned ok for each inspected database. Database corruption is therefore not established, and no database was moved or modified.

    Please advise a supported repair for the arg0/PATH-alias provisioning context that does not require manual ACL edits, moving state databases, disabling the sandbox, or using a shell-based patch workaround.

    Privacy/safety: no session context, project names, source code, local user name, Drive identifiers, raw logs, or attachments are included.

  5. JBTradesOA commented on Oct 26, 2026

    @JBTradesOA

    I found a working workaround for my affected Windows Codex Desktop setup.

    I installed Ubuntu under WSL2, completed the initial Ubuntu user setup, changed Codex Desktop’s integrated terminal shell from PowerShell to WSL, and fully restarted Codex Desktop.

    After the restart, the local project was accessed through its WSL path:

    /mnt/c/Users/<user>/Documents/Codex/<project>

    apply_patch can now create and update files in the same project that previously failed under the native Windows/PowerShell execution context. Project logging and normal workspace edits are working again.

    This does not identify or repair the underlying Windows sandbox/arg0-windows issue. It only changes the execution environment and should therefore be treated as a workaround. The original failure remains relevant for users who need or prefer the native Windows environment.

    No manual ACL changes, database modifications, sandbox disabling, or Full Access setting were used.

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

    appbugsandboxtool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions