Skip to content

Windows: daemon install fails with os error 5 at FSCTL_SET_REPARSE_POINT #48853

Closed

Description

@shgef

What happened

codex fails to start because the managed app-server daemon cannot be installed:

Installing daemon from CLI version 0.157.1 into %USERPROFILE%\.codex\packages/app-server-daemon...
Error: Access is denied. (os error 5)
To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).

The install leaves a consistent half-finished state behind, which is the useful clue:

%USERPROFILE%\.codex\packages\app-server-daemon\releases      <- empty directory
%USERPROFILE%\.codex\packages\app-server-daemon\install.lock  <- 0 bytes

So directory creation and lock-file creation both succeed. The failure happens after that, and it is not a plain permission problem.

Root cause

prepare_install_windows.rs (select_release) does not create the current junction directly. On the cold path it creates a temp dir, creates a real directory named current inside it, then converts that existing directory into a mount-point junction via DeviceIoControl(..., FSCTL_SET_REPARSE_POINT, ...), and finally renames it into place.

That conversion is what returns ERROR_ACCESS_DENIED. Creating a new junction on the same machine, in the same directory, works fine:

# both succeed, in .codex\packages and in %TEMP%
mklink /J link target
New-Item -ItemType Junction -Path link -Target target

Only the "open an existing directory with GENERIC_WRITE + FILE_FLAG_OPEN_REPARSE_POINT and set a reparse point on it" path is blocked. On this machine CodexSandboxService.OpenAI.Codex is running, and a filter driver blocking reparse-point writes (a standard junction-escape mitigation) would produce exactly this. If that is Codex's own sandbox driver, Codex is blocking its own daemon install.

Reproduction

Remove-Item "$env:USERPROFILE\.codex\packages\app-server-daemon" -Recurse -Force
codex app-server daemon start   # -> Error: Access is denied. (os error 5)

codex app-server daemon start reproduces this without a tty, which is much easier to automate than the TUI path (the TUI exits with stdin is not a terminal before reaching the install step).

Ruled out

Each of these was tested and eliminated, so please don't re-litigate them:

Hypothesis Evidence against
File lock / stale install.lock install.lock opens exclusively; no process holds it
Missing write permission Manually copying the 322 MB codex.exe into the target path succeeds
ACL on .codex The explicit CodexSandboxUsers: ReadAndExecute ACE looks guilty but isn't — the user has FullControl at every level, and that group only contains the two Codex sandbox accounts
Directory location Pointing CODEX_HOME at a brand-new %TEMP% dir fails identically
Insufficient privilege Codex refuses to run elevated: "start the Windows daemon from a non-elevated terminal"
Antivirus Defender service not running (Get-MpPreference returns 0x800106ba)
Job Object (#44503) Launching via WMI to escape the job gives the same os error 5; a real job problem reports a different, explicit error
Version regression (#48043) 0.156.1 fails identically. Downgrading does not help here, so this is a distinct bug from #48043
Disk space 19.4 GiB free

RUST_LOG=trace only yields a backtrace with all-<unknown> symbols, which is why the source reading was necessary.

Workaround

Building the layout by hand makes the installer take the warm path and skip the conversion entirely. The daemon then starts and runs normally:

$root = "$env:USERPROFILE\.codex\packages\app-server-daemon"
$src  = "<npm global>\@openai\codex\node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe"
$rel  = "$root\releases\0.157.1-x86_64-pc-windows-msvc"
New-Item -ItemType Directory -Force -Path "$rel\bin"
Copy-Item $src "$rel\bin\codex.exe" -Force
cmd /c "mklink /J `"$root\current`" `"$rel`""
codex app-server daemon start

Result:

{"status":"running","backend":"pid","managedCodexVersion":"0.157.1","cliVersion":"0.157.1","appServerVersion":"0.157.1"}

codex doctor then reports ✓ app-server running. The layout contract came from managed_install.rs: current\bin\codex.exe (packaged) with current\codex.exe as the legacy fallback, and the release directory must be <three-part version>-<target triple>.

This has to be redone after every CLI upgrade, since a version mismatch triggers the updater and walks back into the same code path.

Suggested fix

Treat the reparse-point conversion as best-effort: if FSCTL_SET_REPARSE_POINT fails with ERROR_ACCESS_DENIED, fall back to creating the junction directly (which works even when converting does not), or fall back to a plain directory / the legacy standalone layout instead of failing the whole install. An unavailable junction should degrade to ephemeral mode rather than block startup.

Environment

  • Windows 10 Pro/Home 10.0.19045 x64
  • codex-cli 0.157.1 (also reproduced on 0.156.1), npm global install
  • Terminal: VS Code integrated terminal, non-elevated
  • [windows] sandbox = "elevated" in config.toml; codex doctor reports sandbox provisioning complete and 0 failures
  • CodexSandboxService.OpenAI.Codex running

Related but distinct: #48043 (same subsystem, but downgrading fixes that one and not this), #44503 (Job Object check, different error message).

Activity

  1. added
    bug
    CLI
    windows-os
    app-server
    on Sep 28, 2026
  2. github-actions commented on Sep 28, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. shgef commented on Sep 28, 2026

    @shgef
    Author

    Correction to the workaround above: copying only bin\codex.exe is not sufficient.

    Doing that does let the daemon start, and codex doctor reports app-server running with 0 failures — but actual use then fails with codex-code-mode-host.exe missing, and even read-only commands cannot start. The managed release directory has to mirror the whole vendor tree (45 files, ~425 MB), not just the main binary:

    bin\codex.exe
    bin\codex-code-mode-host.exe
    codex-path\rg.exe
    codex-resources\codex-command-runner.exe
    codex-resources\codex-windows-sandbox-setup.exe
    codex-resources\voice\...        (voice host + GStreamer/glib DLLs)
    codex-package.json
    

    So the copy step should mirror the entire vendor directory into the release directory, with the daemon stopped first:

    codex app-server daemon stop
    Copy-Item (Join-Path $vendorDir '*') -Destination $releaseDir -Recurse -Force
    codex app-server daemon start

    Worth noting for the fix itself: daemon start succeeding and doctor showing all-green are not sufficient health signals here. Neither one validates that the managed release is complete, so a partially-populated release directory looks perfectly healthy right up until a tool invocation fails. A manifest or completeness check on the release directory would catch that.

  4. francis1104 commented on Sep 28, 2026

    @francis1104

    Additional confirmation from another Windows standalone installation (Codex CLI 0.157.1):

    I hit the same daemon install failure:

    Installing daemon from CLI version 0.157.1 into %USERPROFILE%\.codex\packages/app-server-daemon...
    Error: Access is denied. (os error 5)
    

    The standalone 0.157.1 release itself was complete. These all existed:

    %USERPROFILE%\.codex\packages\standalone\releases\0.157.1-x86_64-pc-windows-msvc\bin\codex.exe
    %USERPROFILE%\.codex\packages\standalone\releases\0.157.1-x86_64-pc-windows-msvc\bin\codex-code-mode-host.exe
    %USERPROFILE%\.codex\packages\standalone\releases\0.157.1-x86_64-pc-windows-msvc\codex-resources\codex-command-runner.exe
    

    I then manually mirrored the complete standalone release into:

    %USERPROFILE%\.codex\packages\app-server-daemon\releases\0.157.1-x86_64-pc-windows-msvc
    

    and created the current junction directly in a normal, non-elevated PowerShell:

    New-Item -ItemType Junction `
      -Path "$env:USERPROFILE\.codex\packages\app-server-daemon\current" `
      -Target "$env:USERPROFILE\.codex\packages\app-server-daemon\releases\0.157.1-x86_64-pc-windows-msvc"

    That succeeded immediately.

    After that:

    codex app-server daemon start

    returned successfully:

    {"status":"started","backend":"pid","managedCodexVersion":"0.157.1","cliVersion":"0.157.1","appServerVersion":"0.157.1"}

    And codex doctor reported:

    25 ok · 2 notes · 0 warn · 0 fail
    

    with:

    Background Server
    ✓ app-server   running (ephemeral mode)
    status         running
    app-server version 0.157.1
    

    So this independently confirms the same pattern described here: the Codex-managed daemon installation path fails with os error 5, while creating the junction directly with PowerShell works on the same machine, and the daemon runs normally once the expected release layout is constructed manually.

    中文补充:

    另一台 Windows standalone 0.157.1 环境也复现了完全相同的 Access is denied (os error 5)。确认 standalone release 本身完整后,手工复制完整 release 到 app-server-daemon\releases\0.157.1-x86_64-pc-windows-msvc,再用 PowerShell 的 New-Item -ItemType Junction 直接创建 current junction,可以立即成功。

    随后 codex app-server daemon start 正常启动,codex doctor 显示 0 warn · 0 fail。这进一步说明问题不是普通文件写权限或 release 内容损坏,而是 Codex 自己的 Windows daemon/junction 安装路径。

  5. rajumb0232 commented on Sep 29, 2026

    @rajumb0232

    After the latest Codex CLI update on Windows, running codex failed immediately with Error: Access is denied. (os error 5) and suggested --no-daemon. I reproduced it from two separate repositories. Reinstalling my previous Codex version restored normal startup with plain codex.

    The --no-daemon workaround launched Codex, but touchpad movement then inserted [M#...] sequences into the prompt. I’m treating that as a separate TUI issue. I can share the exact working and failing version numbers once confirmed.

  6. kge-lab commented on Sep 29, 2026

    @kge-lab

    Additional reproduction on Windows 11 x64 with PowerShell and Codex CLI 0.159.0.

    Command:

    codex resume

    Actual result:

    Error: failed to open daemon process: 액세스가 거부되었습니다. (os error 5)
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    

    Workaround:

    codex resume --no-daemon

    The workaround works successfully, which confirms that the failure is limited to background daemon startup. The normal interactive resume path is blocked on 0.159.0 as well.

  7. rajumb0232 commented on Oct 6, 2026

    @rajumb0232

    Additional report on 2026-10-06: normal Codex CLI startup is still blocked on Windows with codex-cli 0.160.1.

    Environment: Windows, PowerShell. Exact Windows build, installation method, and terminal elevation status have not been collected.

    Observed output (working directory omitted):

    PS> codex --version
    codex-cli 0.160.1
    PS> codex
    Error: Access is denied. (os error 5)
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    

    This occurred immediately after updating. The same error also occurred on the previous installed version, whose version number is not available.

    Expected: plain codex starts normally with the background server enabled.
    Actual: startup exits with the error above, blocking use.

    The user is choosing to roll back rather than bypass the background server. No successful rollback or --no-daemon test has been reported for this occurrence.

    The error text matches this issue, but without diagnostics we cannot confirm that the failing operation is the same reparse-point operation described in the original report. Please investigate whether the fix for this closed issue covers normal CLI startup on 0.160.1, or track this as a separate daemon startup failure if appropriate.

  8. RazvanVC commented on Oct 8, 2026

    @RazvanVC

    Windows daemon installation: confirmed recovery on 0.160.0 and successful upgrade to 0.161.0

    Posting an anonymized troubleshooting report from a Windows 11 Enterprise x64 machine (build 26100), using Windows PowerShell and the standalone Codex CLI installer. This appears related to #48853, but we did not trace the failing Windows API and cannot confirm the same underlying cause.

    Symptoms

    Normal codex startup failed with:

    Error: Access is denied. (os error 5)
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    

    codex --no-daemon worked. Running the foreground codex app-server also started the process. That command expects JSON-RPC, so typing ordinary sentences into it caused JSON deserialization errors; those were not evidence of the original startup failure.

    The more useful reproduction was:

    codex app-server daemon start
    Installing daemon from CLI version 0.161.0 into %USERPROFILE%\.codex\packages/app-server-daemon...
    Error: Access is denied. (os error 5)
    

    Findings

    • The failure occurred on 0.161.0 and still occurred after downgrading the standalone CLI to 0.160.0. The downgrade alone did not fix it.
    • codex doctor reported a consistent installation, configured authentication, healthy state databases, and successful HTTP/WebSocket checks. These checks did not establish that daemon installation was healthy.
    • The daemon package directory and its releases directory granted the normal Windows account FullControl.
    • Multiple incomplete .staging.* directories accumulated under %USERPROFILE%\.codex\packages\app-server-daemon\releases.
    • Comparing the latest 0.160.0 staging tree with its standalone source package showed that bin\codex-code-mode-host.exe was the only missing source file. A manual copy of that source file to a separate diagnostic directory succeeded. This is a diagnostic clue, not proof that the missing file caused the original error.
    • Changing temporary-folder permissions, resetting daemon state, and adding Defender process exclusions did not resolve normal startup. The Windows event records inspected showed the exclusion configuration changes but no matching Codex block. This does not conclusively exclude every endpoint-security mechanism.

    What worked

    The incomplete daemon staging directories were moved to a backup outside the releases directory. Then the official PowerShell installer was invoked for the daemon package separately, targeting 0.160.0, instead of relying on the CLI's failing automatic daemon installation step.

    The installer source at https://chatgpt.com/codex/install.ps1 (redirecting to releases.openai.com) supported both -Release and CODEX_INSTALL_DAEMON_ONLY=1 at the time of testing. The daemon-only environment variable is an implementation detail observed in the installer, not a promise of a stable public interface.

    The essential installer invocation was equivalent to:

    # Use a normal, non-elevated PowerShell under the account that runs Codex.
    # Close active CLI work before changing/restarting its shared daemon.
    $savedDaemonOnly = $env:CODEX_INSTALL_DAEMON_ONLY
    try {
        $env:CODEX_INSTALL_DAEMON_ONLY = '1'
        $installer = Invoke-RestMethod 'https://chatgpt.com/codex/install.ps1'
        & ([scriptblock]::Create($installer)) -Release '0.160.0'
    } finally {
        $env:CODEX_INSTALL_DAEMON_ONLY = $savedDaemonOnly
    }

    Execution detail: the agent session encountered a Schannel download error, so it used Node's TLS implementation as the download transport while retaining the official installer's package/checksum checks. The equivalent plain PowerShell snippet above was not separately tested end-to-end in that session.

    After installation, the daemon's current junction targeted the complete 0.160.0 release. The daemon executable reported 0.160.0, and the previously missing helper's SHA-256 matched the standalone source package. The user then confirmed that normal codex startup worked without --no-daemon.

    Confirmed upgrade to 0.161.0

    Both CLI and daemon packages were subsequently installed at 0.161.0 using the same installer approach. A restart from the agent sandbox was blocked by private-directory validation after temporary access grants were added. The user then ran a narrowly scoped cleanup/restart script from their normal PowerShell. It removed only those two maintenance-related access entries, restarted the daemon, and checked the CLI and running daemon versions.

    The user supplied this successful restart result on October 8, 2026 (unnecessary identifiers and paths omitted):

    {
      "status": "restarted",
      "backend": "pid",
      "managedCodexVersion": "0.161.0",
      "cliVersion": "0.161.0",
      "appServerVersion": "0.161.0"
    }

    A subsequent normal codex -C <project-directory> launch established a session and reported token usage, without the original access-denied error. The transcript ended with Disconnected from this task. Any running work continues. and a resume command. This confirms recovery from the daemon installation/startup failure on 0.161.0; it does not establish why that session disconnected or prove that every CLI feature was tested.

    The private-directory validation during agent-driven maintenance was a separate observation. Avoid blanket ACL resets or broad antivirus exclusions based solely on os error 5. No credentials, full diagnostic logs, company identifiers, or user-specific paths are included here.

    It would help if the automatic daemon installer reported the failing file or operation, and if maintainers could confirm a supported repair command for this incomplete-package state.

  9. etraut-openai commented on Oct 8, 2026

    @etraut-openai
    Contributor

    @rajumb0232 and @RazvanVC, thanks for the additional details. We have a fix in place for this issue. It will be included in the 0.162.0 release, which should be published within the next 12 hours.

  10. WoozChucky commented on Oct 10, 2026

    @WoozChucky

    14. @rajumb0232 and @RazvanVC, thanks for the additional details. We have a fix in place for this issue. It will be included in the 0.162.0 release, which should be published within the next 12 hours.

    Just updated to 0.162.1 and I'm getting the same error I believe. Are you sure this fix works ?

    Error: failed to open daemon process: Access is denied. (os error 5)
    To work without the background server, rerun the same command with --no-daemon (including resume or fork and its arguments).
    
  11. etraut-openai commented on Oct 10, 2026

    @etraut-openai
    Contributor

    @WoozChucky, there are potentially multiple causes of an "Access is denied" error. 0.162.1 fixed the most common. It's possible you're hitting a different one. Please open a new bug report. After you see the failure, relaunch with --no-daemon and use /feedback to upload your logs, then include the session ID in the bug report. That will help us further diagnose the cause of the "Access is denied" error you're seeing on your system.

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

    CLIapp-serverbugwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions