Skip to content

File paths on Windows improperly treat their UNC representation as canonical #10347

Open

Description

@ofek

Context

As shown in rust-lang/rust#42869, the choice to have std:fs:canonicalize return UNC paths is viewed as a mistake. The docs mention:

[...] it may be incompatible with other applications (if passed to the application on the command-line, or written to a file another application may read).

The word "may" is quite inaccurate though because in reality support for UNC paths is astonishingly rare, even for internal Windows APIs.

What issue are you seeing?

Codex appears to use these paths internally and leaks its usage, for example in how every project path in ~\.codex\config.toml is stored as UNC:

[projects.'\\?\C:\Users\ofek\Desktop\code\datadog-agent']
trust_level = "trusted"

[projects.'\\?\C:\Users\ofek\Desktop\code\hatch']
trust_level = "trusted"

[projects.'\\?\C:\Users\ofek\Desktop\code\msgspec']
trust_level = "trusted"

UNC paths should only ever be used internally, never exposed, to maintain interoperability with the vast majority of software and to reduce user confusion when seen.

Issues caused by UNC paths

Solution

One of the following two approaches must be chosen:

  1. Keep UNC as the internal representation and strip the prefix upon external access. For example, when writing the paths to a file, during subprocess execution, or using Windows APIs that don't support UNC.
  2. Change the internal representation to the one that is universally recognized and document how to enable a setting that would allow Codex to declare itself as long-path aware.

The former is the current approach that is obviously difficult to apply ubiquitously so I'd recommend the latter, which is the modern way offered by Microsoft (where possible). They recommend embedding an application manifest directly within the binary. This is pretty easy using something like the embed-manifest crate or manually setting the associated linker options.

The path normalization should likely use the normalize_for_native_workdir core utility, introduced in #13742, that relies on the de facto standard dunce crate.

Activity

  1. added
    bugSomething isn't working
    on Feb 1, 2026
  2. added
    CLIIssues related to the Codex CLI
    windows-osIssues related to Codex on Windows systems
    on Feb 1, 2026
  3. changed the title [-]Project locations are stored as UNC paths in config on Windows[/-] [+]Paths on Windows[/+] on Mar 7, 2026
  4. changed the title [-]Paths on Windows[/-] [+]File paths on Windows improperly treat their UNC representation as canonical[/+] on Mar 7, 2026
  5. added
    agentIssues related to the core agent loop
    and removed
    CLIIssues related to the Codex CLI
    on Mar 16, 2026
  6. BradenHartsell commented on May 5, 2026

    @BradenHartsell

    @etraut-openai any update on this? I'd really like to be able to use the worktree feature in codex.

  7. walter-seethaler commented on Sep 1, 2026

    @walter-seethaler

    Please add #35380 to the list of UNC-related Windows path failures. It is a concrete \\wsl.localhost case in which Codex accepts the UNC workspace root, then passes it into Windows sandbox ACL setup. GetSecurityInfo / GetNamedSecurityInfoW fail on the WSL provider, and the entire setup refresh aborts before any command can run—even when the requested command uses a separate local C:\ working directory.

    This is more than leaked extended-path formatting, but it belongs in the same general tracking area because the UNC-backed root is accepted and propagated into a subsystem that cannot operate on that path class.

  8. douglasg14b commented on Sep 17, 2026

    @douglasg14b

    Is this why I can't use worktrees with Codex at all??

    I just constantly get reparse-point errors.

    Which is honestly incredibly frustrating.

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

    agentIssues related to the core agent loopbugSomething isn't workingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions