Repository navigation
Description
What version of the Codex App are you using (From "About Codex" dialog)?
26.1002.7124.0. This is the installed MSIX package version (OpenAI.Codex, x64) read with Get-AppxPackage; I did not read it from the About dialog. The bundled CLI recorded in the session metadata is codex-cli 0.162.0-alpha.2.
What subscription do you have?
Not provided
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64 (Windows 11 Pro, build 26200)
What issue are you seeing?
In one Codex Desktop chat on Windows (sandbox policy workspace-write), read-only Git commands against a normal, non-bare repository with a .git directory behave inconsistently:
git rev-parsequeries succeed and report a work tree.git statusandgit difffail withfatal: this operation must be run in a work tree(exit code 128).
About the repository:
- It is a plain clone:
.gitis a directory, HEAD is detached, and it has no linked worktrees and no remote. core.bare=falseandcore.worktreeis not set.
On the same repository:
- In an ordinary, unsandboxed shell on the same machine,
git status --shortandgit diff --quiet HEAD --both exit 0 (Git for Windows 2.55.0.windows.1). - In an earlier Codex chat on the same day,
git status --shortsucceeded (see the steps below).
Output recorded in the failing chat. The working directory had been set to the repository root with Set-Location; paths are redacted.
git rev-parse HEAD -> <commit sha> exit 0
git rev-parse --show-toplevel -> C:/<WORKSPACE>/<repo> exit 0
git rev-parse --git-dir -> .git exit 0
git rev-parse --absolute-git-dir -> C:/<WORKSPACE>/<repo>/.git exit 0
git rev-parse --git-common-dir -> .git exit 0
git rev-parse --show-prefix -> (empty) exit 0
git rev-parse --is-inside-work-tree -> true exit 0
git rev-parse --is-inside-git-dir -> false exit 0
git rev-parse --is-bare-repository -> false exit 0
git config --show-origin --get core.bare -> file:.git/config false exit 0
git config --show-origin --get core.worktree -> (empty) exit 1
GIT_DIR / GIT_WORK_TREE / GIT_COMMON_DIR -> all unset
Test-Path .git -> True (Directory, Hidden)
git status --short -> fatal: this operation must be run in a work tree exit 128
git status --porcelain=v1 --untracked-files=no -> same message exit 128
git diff --quiet HEAD -- -> same message exit 128
git ls-files --error-unmatch <file> also reported one file as unknown to Git. That file is intentionally untracked, so this result is expected and is not part of the problem.
Earlier in the same chat, before the working directory was changed, every command of the form git -C C:\<WORKSPACE>\<repo> ... failed with the message below. That includes rev-parse HEAD, which later succeeded after Set-Location.
fatal: cannot change to 'C:\<WORKSPACE>\<repo>': Permission denied
Reading files in the repository from PowerShell in that chat worked: Get-Item, opening a file for reading, and Get-FileHash all succeeded.
What steps can reproduce the bug?
This is what was observed. I have not yet tried a minimal reproduction from a clean setup.
- Codex Desktop on Windows 11, sandbox policy
workspace-write.~/.codex/config.tomlcurrently contains[windows] sandbox = "elevated". The Windows sandbox mode itself is not recorded in the session log; the config file was last modified within a second of the failing chat's start. - The chat's project folder (its cwd) was a folder under the user's OneDrive Documents folder. That path contains non-ASCII characters (the localized Documents folder name), and the project folder name contains a space. The repository lives elsewhere, at
C:\<WORKSPACE>\<repo>(an ASCII path, not under OneDrive).- The effective file-system policy in the session log (
file_system_sandbox_policy) for this chat is:- filesystem root:
read - the project folder:
write - the per-session
.codex\visualizations\...folder:write - tmpdir and slash_tmp:
write
- filesystem root:
- So the repository was covered only by the
readentry for the root.
- The effective file-system policy in the session log (
- In that chat, run
git -C C:\<WORKSPACE>\<repo> status --short --untracked-files=no. Result:fatal: cannot change to ...: Permission denied. - Run
Set-Location C:\<WORKSPACE>\<repo>, then the commands listed above. Result:rev-parsesucceeds;statusanddifffail with "this operation must be run in a work tree".
For comparison: in an earlier chat on the same day, the project folder (cwd) was C:\<WORKSPACE>, the parent folder of the repository. Its effective file-system policy gave C:\<WORKSPACE> write access. There, git -C C:\<WORKSPACE>\<repo> status --short succeeded and listed the untracked files. The session metadata shows the same sandbox policy type (workspace-write) and the same CLI version for both chats.
What is the expected behavior?
Read-only Git inspection (git status, git diff) should work in a normal work tree that the chat can read. If the path is outside what the sandboxed process may use, I would expect an error that says so, rather than Git reporting that the directory is not a work tree.
Additional information
Status of the cause: the outputs above are copied from the Codex session log; the cause has not been determined.
One possible explanation (not verified):
- In Git's
setup.c,setup_work_tree()dies with "this operation must be run in a work tree" when no work tree is found, and also when thechdirinto the work tree fails. statusanddiffgo through that step; therev-parsequeries above do not.- Together with the earlier
cannot change to ...: Permission denied, the message may therefore be a downstream effect of a refusedchdirinto a folder that the policy grants onlyread, even though reading files there succeeded.
I have not confirmed this. I also have not confirmed:
- which Windows access check is involved;
- whether the OneDrive or non-ASCII project path plays any role;
- which
git.exethe sandboxed process used. On the host,giton PATH is Git for Windows 2.55.0.windows.1.
A separate observation on the same machine and day, which may or may not be related. In a chat whose cwd was C:\<WORKSPACE> (policy write on C:\<WORKSPACE>), a Python 3.12 test suite failed during setup:
- With the default TEMP (
...\AppData\Local\Packages\sandbox.{...}\AC\Temp):tempfile.TemporaryDirectory()was created, butos.mkdirof a subdirectory inside it raisedPermissionError: [WinError 5]. - With TMP/TEMP pointed to a folder inside
C:\<WORKSPACE>: creating and writing a temporary file succeeded, butos.link(tmp, path)(a hard link in the same directory) raisedPermissionError: [WinError 5].
Outside the sandbox, the same tests pass on the same NTFS volume. Hard links work normally there, both within a directory and across directories, and linking onto an existing file raises FileExistsError as expected.
Possibly related issues (not identical):
- [Windows] Restricted-token sandbox: --add-dir doesn't stamp SID, and os.replace() fails on stamped paths #22044: restricted-token SID stamping;
os.replaceWinError 5 - Windows elevated sandbox: WinError 5 when creating directory inside workspace-write root #52339: WinError 5 creating a directory inside a workspace-write root
- [Windows] Sandbox: Access denied on existing workspace descendants after sandbox SID change #46213: access denied on existing workspace descendants after a SID change
- Windows sandbox: Path.resolve(strict=True) fails with WinError 5 in default execution, succeeds in approved outside execution #51989:
Path.resolve(strict=True)WinError 5 in the sandbox
#34828 shows the same Git message, but with a different cause (macOS, bare common-dir).
Questions:
- Is this a known limitation or expected behavior of the Windows sandbox, or more likely an environment or configuration problem on my side?
- Is a repository outside the chat's project folder expected to allow file reads but refuse a
chdirinto it? - Is hard-link creation (
os.link/CreateHardLink) expected to be refused inside aworkspace-writeroot? - What is the recommended way to inspect such a repository with Git while keeping the sandbox enabled? For example, should the repository itself (or its parent) be the chat's project folder?
Activity
executiveos2026 commentedon Nov 11, 2026
Additional reproduction: Codex Desktop Git failure and PowerShell filesystem initialization error
I can reproduce the Git working-tree failure described in this issue on Windows using Codex Desktop.
Observed behavior
Inside Codex Desktop, the following command fails:
Output:
Exit code: 1.
This occurs consistently, including in newly created Codex conversations.
Repository verification
The repository is a normal, non-bare Git working repository.
Inside Codex:
git rev-parse --show-toplevelsucceeds.git rev-parse --is-inside-work-treereturnstrue.git rev-parse --is-bare-repositoryreturnsfalse.git ls-filessucceeds..git/indexexists and is readable.core.bare=false.core.worktreeoverride is configured.GIT_DIR,GIT_WORK_TREE, andGIT_COMMON_DIRare unset.Despite these results,
git statusfails.Comparison outside Codex Desktop
The identical Git installation works in ordinary Windows PowerShell.
Git version:
2.54.0.windows.1Running:
Returns:
The repository is clean.
Sandbox testing
The failure persists under:
However, invoking the standalone Codex CLI with MXC succeeds.
The standalone MXC test returned:
Exit code: 0.
Execution environment
Both the PowerShell/.NET current directory and native
cmd.execurrent directory correctly identify the repository root.Launching Git through
cmd.exefrom inside Codex Desktop produces the same failure.The issue is therefore not explained by an incorrect working directory or by using a different Git installation.
Runtime information
The problem persisted after the Codex workspace runtime was updated to:
26.1110.11613Codex Desktop uses a packaged Windows runtime.
The built-in dependency diagnostic reports that dependencies are healthy.
Impact
This prevents Codex Desktop from reliably inspecting Git working-tree status, which interferes with normal development workflows.
The existing repository works correctly outside Codex Desktop.
Requested investigation
Please investigate whether Codex Desktop's packaged Windows execution environment is interfering with PowerShell filesystem-provider initialization or Git working-tree access.
The successful standalone MXC CLI test, compared with the failing Desktop execution, may help isolate the affected component.
No Git repository corruption has been established.
I can provide sanitized diagnostic excerpts if additional information is required.