Repository navigation
Description
What version of the Codex App are you using (From “About Codex” dialog)?
26.616.71553
What subscription do you have?
Plus
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
Codex Desktop on Windows appears to initialize the PowerShell shell tool with split and inconsistent filesystem state. The managed/.NET current directory is set to the requested workspace, but PowerShell's provider/session state and native child-process cwd are not. This causes commands to run from an unrelated drive (F:/, in my case) or temp directory, prevents normal PowerShell cmdlets from resolving, and prevents native tools like git from seeing the workspace. Additionally, the PowerShell FileSystem provider lacks the C: drive entirely, even though .NET APIs can access C:\... paths.
Initial Symptoms With F: Mounted
The shell tool was invoked with:
workdir = C:\Users\user.name\Documents\Codex\2026-06-23\iObserved:
[System.IO.Directory]::GetCurrentDirectory()
# C:\Users\user.name\Documents\Codex\2026-06-23\i
$ExecutionContext.SessionState.Path.CurrentFileSystemLocation
# F:\
cmd.exe /c cd
# F:\PowerShell filesystem drives were:
Temp | FileSystem | C:\Users\U9974~1.NAM\AppData\Local\Temp\
F | FileSystem | F:\
Missing expected drives:
C:
I:
Core PowerShell management cmdlets were unavailable:
Get-Location
# The term 'Get-Location' is not recognized...
Get-PSDrive
# The term 'Get-PSDrive' is not recognized...PSModulePath included the expected PowerShell 7 module directory:
C:\Program Files\PowerShell\7\Modules
The module file existed according to .NET APIs:
[System.IO.Directory]::Exists('C:\Program Files\PowerShell\7\Modules\Microsoft.PowerShell.Management')
# True
[System.IO.Directory]::GetFiles('C:\Program Files\PowerShell\7\Modules\Microsoft.PowerShell.Management')
# C:\Program Files\PowerShell\7\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1But importing failed:
Import-Module Microsoft.PowerShell.Management
# The specified module 'Microsoft.PowerShell.Management' was not loaded because no valid module file was found in any module directory.PowerShell provider path resolution failed for absolute C:\... paths:
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath('C:\Users\user.name\Documents\Codex\2026-06-23\i')
# Cannot find drive. A drive with the name 'C' does not exist.After Relaunching Codex And Ejecting F:
I fully relaunched Codex and ejected the removable F:\ drive.
Observed:
[System.IO.Directory]::GetCurrentDirectory()
# C:\Users\user.name\Documents\Codex\2026-06-23\i
$ExecutionContext.SessionState.Path.CurrentFileSystemLocation
# Temp:\
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath('.')
# C:\Users\U9974~1.NAM\AppData\Local\Temp\
cmd.exe /c cd
# C:\Users\U9974~1.NAM\AppData\Local\Temp\PowerShell filesystem drives then included only:
Temp | FileSystem | C:\Users\U9974~1.NAM\AppData\Local\Temp\
Still missing:
C:
I:
Core management cmdlets were still unavailable:
Get-Location
# The term 'Get-Location' is not recognized...
Get-PSDrive
# The term 'Get-PSDrive' is not recognized...Native commands could not access the workspace:
cmd.exe /c "dir C:\Users\user.name\Documents\Codex\2026-06-23\i"
# Access is denied.
git -C C:\Users\user.name\Documents\Codex\2026-06-23\i status --short
# fatal: not a git repository (or any of the parent directories): .gitBut .NET APIs inside the shell could still see the workspace:
[System.IO.Directory]::Exists('C:\Users\user.name\Documents\Codex\2026-06-23\i')
# True
[System.IO.Directory]::GetFileSystemEntries('C:\Users\user.name\Documents\Codex\2026-06-23\i')
# C:\Users\user.name\Documents\Codex\2026-06-23\i\outputs
# C:\Users\user.name\Documents\Codex\2026-06-23\i\workWhat steps can reproduce the bug?
Reproducibility
These commands will reproduce the important state:
$ExecutionContext.SessionState.Drive.GetAll() | ForEach-Object { "$($_.Name)|$($_.Provider.Name)|$($_.Root)|$($_.CurrentLocation)" }
[System.IO.Directory]::GetCurrentDirectory()
$ExecutionContext.SessionState.Path.CurrentFileSystemLocation
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath('.')
cmd.exe /c cd
Get-Location
Get-PSDrive -PSProvider FileSystem
git status --shortWhat is the expected behavior?
When the shell tool is invoked with workdir = C:\Users\user.name\Documents\Codex\2026-06-23\i:
- PowerShell provider cwd should be the workspace, not
F:\orTemp:\ - Native child processes should inherit the workspace cwd
- The FileSystem provider should expose at least the workspace drive,
C: - Built-in cmdlets from
Microsoft.PowerShell.Management, such asGet-Location,Get-ChildItem, andGet-PSDrive, should be available or importable - Native commands such as
git statusshould execute in the workspace
Additional information
Why Care?
This breaks normal Codex repository workflows on Windows:
git,cmd, and other native tools run from the wrong directory- Relative paths resolve to the wrong location
- Absolute workspace paths may fail through PowerShell provider/native tooling
- Common PowerShell commands fail because core modules/cmdlets are unavailable
- The assistant may misdiagnose cwd/env-var issues as repo problems
Potential Culprit(s)
This looks like a Codex Windows shell-host or sandbox initialization issue. The host seems to patch the managed/.NET current directory to the requested workspace but does not initialize PowerShell's FileSystem provider drives, provider cwd, or native subprocess cwd consistently.
The presence of a removable F:\ drive influenced the wrong cwd, but after ejecting it the issue persisted with Temp:\, which suggests F:\ was a symptom or selected fallback rather than the root cause.
My workstation does have a dual PowerShell/PwSh installation (5.1.26100.8655 and 7.5.5), which may be a contributing environment detail, but even that should not normally cause a PowerShell 7 runspace to omit C: from FileSystem PSDrives while .NET can access C:\.
Suggested Areas of Concern
- How Codex Desktop creates Windows PowerShell runspaces for the shell tool
- Whether sandboxing/brokering strips or fails to add the workspace drive as a FileSystem PSDrive
- Whether the host sets only
[System.IO.Directory]::CurrentDirectorybut not PowerShell provider location - Whether native child process cwd is initialized from a stale parent cwd rather than the requested
workdir - Whether removable or mapped drives affect initial drive selection/fallback
Activity
arturohernandez10 commentedon Oct 9, 2026
Additional reproduction: PowerShell
InitializeDefaultDriveserror only inside Codex Windows sandboxI'm seeing a related PowerShell filesystem-provider initialization warning in Codex Desktop for Windows when running commands inside its sandbox.
Environment
C:\(not a mapped drive)H:andZ:, point to the same Azure Files SMB share. Storage account and local username omitted for privacy.Exact warning
Steps and observations
Get-PSDrive -PSProvider FileSystemreturnsC:,H:, andZ:, without the startup warning.Get-PSDrive -PSProvider FileSystemreturnsC:andH:but notZ:. TheInitializeDefaultDriveswarning appears before the output; the command still runs.powershell.exe -NoProfile -Command "'PowerShell started successfully'"completes and prints the expected output, but the warning is still shown. Since Codex may launch an outer PowerShell before this nested process, this does not conclusively rule out profiles.Write-Output "sandbox comparison"outside the sandbox, using Codex's approval/escalation mechanism. It printssandbox comparison, exits successfully, and does not show the initialization warning.Expected: PowerShell's FileSystem provider initializes without a warning for commands executed in the Windows sandbox.
Actual: The warning occurs in sandboxed execution, not in normal PowerShell or in the approved unsandboxed Codex command. Commands still execute successfully.
Interpretation: The sandbox environment is the demonstrated trigger, but the root cause is not confirmed. Differences in sandboxed process context, filesystem permissions, or drive visibility may be relevant. There is no evidence yet that either Azure Files mapping is broken. No drives, PowerShell settings, or system permissions were changed during testing.
This is related to #29688, but
C:remains available and the warning is non-fatal in my reproduction.arturohernandez10 commentedon Oct 9, 2026
Environment details for the reproduction above
Collected from a normal, unsandboxed PowerShell session:
26.1002.7124.0OpenAI.Codex_26.1002.7124.0_x64__2p2nqsd0c76g010.0.26200262005.1.26100.95497.6.64.8.9345.0C:\WINDOWSAdditional context
SystemRootvalue above was verified outside the sandbox; its value inside the sandbox has not yet been checked.These details correspond to Codex Desktop version
26.1002.7124.0and Windows build26200.sylw114 commentedon Oct 11, 2026
Additional reproduction on 2026-10-11: explicit workspace cwd, PowerShell falls back to C:\
I reproduced the missing workspace PSDrive / split-cwd behavior in the current Codex Desktop executor. The assistant's environment context and the
exec_commandpayload both specifiedG:\agent, but relative PowerShell commands ran atC:\.Environment:
codex-cli 0.162.0-alpha.17.2(from the executable used by the running desktop session).Microsoft Windows NT 10.0.29680.0, x64.7.6.5.G:\agent, on a local fixed ReFS volume, not a mapped/network drive.The same read-only probe with the same explicit
workdirproduced:Get-LocationC:\G:\agent[Environment]::CurrentDirectoryG:\agentG:\agentGet-PSDrive -Name G[IO.Directory]::Exists('G:\')falsetrue[IO.Directory]::Exists('G:\agent')truetrueSet-Location -LiteralPath 'G:\agent'The mismatch reproduced with both the default startup and
login: false(-NoProfile). A directcmd.exetool invocation using the same sandbox/workdir returnedG:\agentforcd, so the process cwd and the PowerShell provider cwd must be distinguished.Minimal probe (no directory enumeration, no writes):
Actual sandboxed output:
{ "powershellLocation": "C:\\", "processCurrentDirectory": "G:\\agent", "workspaceDriveRegistered": false, "workspaceRootExists": false, "workspaceDirectoryExists": true }The practical impact was observed: an initial unqualified, non-recursive
Get-ChildItemlisted the C: root even though the tool explicitly requested the project workdir. This looks like an execution-environment mismatch rather than the model lacking the project's cwd.I also inspected freshly updated official main,
8c0f7011674145da7e10627769fb221c74fbf7a0:core/src/shell.rs, PowerShell argv construction passes the script via-Command; this path does not initialize or validate the PowerShell provider cwd.windows-sandbox-rs/src/process.rssupplies a process cwd toCreateProcessAsUserW. That alone does not establish a matching PowerShell provider location in the reproduced environment.core/src/context/world_state/environment.rsrenders the model-visible<cwd>.Source inspection is not a claim that I built and reproduced this on main; the runtime reproduction is on the bundled executor version above. The exact cause of the missing drive/root visibility still needs investigation.
Please validate the PowerShell provider cwd before allowing a user script to run, initialize the workspace drive/location where supported, and fail clearly if it cannot be established. Regression coverage should include a workspace on a non-system fixed volume and the missing-PSDrive case; checking only the OS process cwd will miss this behavior.
laipeng101 commentedon Oct 15, 2026
Reproduction with a concrete Win32 error: sandboxed network-drive resolution aborts PowerShell PSDrive initialization
Adding diagnostic evidence to the sandbox-only
InitializeDefaultDrivesreports above. This is a read-only reproduction on Windows 11 using PowerShell 7.6.6 in the Codex Windows command executor. The Codex desktop build number was not collected. It is related to the PSDrive initialization aspect of this issue; I have not reproduced the separate split-CWD symptom.Observed behavior
C:,D:andTemp:.FileSystem/InitializeDefaultDrives). Commands then run and return exit code 0.Get-PSDrive -PSProvider FileSystemshowsC:,D:,W:,X:,Y:,Z:but noTemp:. The additional four drives have network type according to .NET and names/descriptions associated with other mounts.[IO.DriveInfo]::GetDrives()succeeds:C:andD:areFixed, whileW:throughZ:areNetwork, each withIsReady = True.net useandsubstshow no mappings.TEMP/TMPpoint to an AppContainer-specific temporary directory.[IO.Path]::GetTempPath()resolves successfully andTest-Pathconfirms that directory exists.Test-Pathon the local workspace returnedTrue(existence only; no file-read test was performed). Ordinary Chinese output from PowerShell/Python displays correctly. A failed drive-initialization warning appears before script execution and does not appear in the later$Errorcollection.Focused repro: invoke PowerShell's own network-drive resolver
This read-only probe locates and invokes the same
FileSystemProviderhelper used during initialization, reporting the deepest exception without modifying mounts or ACLs:Result (the probe catches the errors, so its process exit code was 0):
Win32 error 5 = ERROR_ACCESS_DENIED.
Why this likely explains the startup warning
In PowerShell
v7.6.6,FileSystemProvider.GetRootPathForNetworkDriveOrDosDevicefirst tries the UNC resolver. OnWin32ExceptionwithdriveInfo.IsReady == true, it falls back toGetSubstitutedPathForNetworkDosDevice.InitializeDefaultDrivescalls that helper for eachNetworkdrive, but the per-drive catch only handlesIOException,SecurityException, andUnauthorizedAccessException;Temp:is added after the drive loop. The fallback implementation can throwWin32Exceptionon a failedQueryDosDeviceWcall.Thus, a permission-denied exception during fallback resolution is consistent with both the startup warning and missing
Temp:. The probe invokes the combined helper, not each underlying API separately; it does not by itself prove thatQueryDosDeviceWis the exact failing API, or which drive is first to abort initialization.This looks like an interaction between the Codex Windows sandbox's visible network-type drives/permissions and PowerShell's insufficiently isolated per-drive error handling. Potential fixes to investigate: make drive visibility/resolution consistent within the sandbox, and/or ensure one inaccessible mapped/pseudo-network drive cannot abort all FileSystem PSDrive initialization. No system settings, drive mappings, ACLs, or project files were changed.
GravuTrad commentedon Oct 22, 2026
Tested PowerShell fix candidate: isolate access-denied errors per drive
Following the network-drive resolver findings above, we reproduced the warning with bundled PowerShell 7.6.5, then rebuilt the actual System.Management.Automation engine twice (original and patched) and tested both inside the affected Codex Windows sandbox. Bundled executor: 0.163.0-alpha.10.2.
This targets the
InitializeDefaultDriveswarning and missingTemp:symptom. We have not reproduced or fixed this issue's separate split-CWD symptom.Mechanism and proposed patch
GetRootPathForNetworkDriveOrDosDevicethrowsWin32Exception, native error 5 / ERROR_ACCESS_DENIED, in the sandbox; the same helper succeeds outside it. The existing per-drive catches inInitializeDefaultDriveshandle IOException, SecurityException and UnauthorizedAccessException, but not Win32Exception. This aborts initialization before Temp registration.Proposed patch against PowerShell v7.6.5:
This skips one inaccessible drive without changing permissions or swallowing other Win32 codes. The helper probe does not establish which underlying native API fails.
Actual engine validation in the affected sandbox
Each rebuilt engine was loaded in a private copy of the same bundled host/runtime/modules, using
-NoLogo -NoProfile -NonInteractive, the same workspace and the same probe. Loaded engine hashes were distinct. Child stderr was captured separately from the unchanged parent shell's warning.All three exited 0 and reported the correct provider and process CWD. The installed engine's SHA256 was verified unchanged.
Six extracted-method checks also passed: original reproduces native error 5; patched method completes; original resolver still denies access afterward; a denied first drive does not prevent later-drive/Temp registration; accessible network drives remain registered; unrelated Win32 error 6 propagates. These are supplementary harness checks, not upstream provider tests.
Build adaptations, identical for both variants: local SDK 10.0.402 instead of 10.0.303; empty root Directory.Build.props/targets to isolate enclosing-project settings; skip git describe when explicit ReleaseTag=7.6.5 is supplied for the source archive. Official resource/type generation was run. Both engine builds completed with zero warnings/errors. This rebuilt the engine, not the entire distribution.
Separate temporary-file problem remains
Both engines can create a file in the sandbox-provided temporary directory, but
File.Move(source, target, overwrite: true)fails there with UnauthorizedAccessException / 0x80070005, including when the destination is new. The same operations succeed inside the workspace.With process-scoped TEMP/TMP pointing to a private workspace subdirectory, the patched-engine probe passes create/move/overwrite/cleanup in both locations. Separately, the existing application test executable passes 94/94 tests under the installed shell with that scoped temporary directory. An earlier redirected suite run under the candidate was interrupted before completion and is not counted as a completed suite.
No persistent environment changes, drive disconnections, ACL changes or security relaxation were made for these comparisons. The PowerShell patch does not fix the temporary-directory restriction or pre-start sandbox errors.
Please review this narrowly filtered catch with PowerShell maintainers, add upstream provider regression coverage, and assess integrating a corrected bundled engine into Codex. The sandbox temporary-directory rename behavior merits separate investigation.
Only this sanitized report and source diff are shared; no private logs, binaries, machine identifiers or project paths are attached.
GravuTrad commentedon Oct 22, 2026
Follow-up: temporary-file rename failure isolated; explicit filesystem grant fixes the tested directory
We investigated the separate temporary-file problem mentioned in the previous comment. This is now more specific than moving TEMP to the workspace.
Native reproduction
In the sandbox-provided AppContainer temporary directory, using fresh disposable files:
The same probes succeed in the workspace. Outside the sandbox, they also succeed against the exact same recorded AppContainer temp directory, not a different user temp directory. No ACL changes were made. This rules out a failure unique to PowerShell/.NET and does not support simply adding DELETE rights to the source.
Tested policy correction
We launched a fresh Codex sandbox with:
Conceptual configuration (placeholder path; not a broad grant to Packages or a user profile):
In that single sandbox invocation:
All eight rename variants, including replacement and the absolute native NT call, pass on the explicitly granted temp path. The read-only control confirms the sandbox was enforcing restrictions. The command exited 0; all disposable probe directories were cleaned up.
This is a successful fresh-sandbox policy experiment, not a live mutation or repair of the original sandbox. It demonstrates that explicit filesystem authorization makes the affected recorded directory support normal rename semantics. It does not identify the exact Windows enforcement implementation responsible for the implicit-temp inconsistency.
Integration recommendation
Ensure that the final per-sandbox temporary directory actually used by child processes is consistently included in the explicit native filesystem policy when the canonical permission profile permits temporary writes. Resolve/provision this directory before final policy construction where supported, and keep the child's effective TEMP/TMP aligned with that directory. Do not grant the entire Packages directory, weaken read-only exclusions, or authorize a temp path when the selected policy forbids temporary writes.
Add an integration test that launches the real sandbox and exercises create, rename to a new name, replacement with content verification, deletion, and a read-only negative control. Checking only directory existence or successful file creation misses this defect.
Relevant source inspection (not a rebuilt Codex claim): temporary-path materialization uses the supplied command environment. Maintainers should compare those resolved paths with the effective AppContainer TEMP/TMP after process launch. A mismatch is a hypothesis to verify, not asserted as the proven internal cause.
One experiment detail: adding legacy sandbox_workspace_write.writable_roots while selecting :workspace did not supply the needed explicit grant. The named profile above did. The current built-in profile resolver explicitly ignores that legacy roots field for the built-in profile.
No installed binary, persistent configuration, ACL, or drive mapping was changed. The earlier 94/94 application-suite result used workspace TEMP/TMP; it was not rerun for this narrower policy experiment. The PowerShell initialization patch remains a separate fix.
jorgebaptista commentedon Nov 4, 2026
The same split state happens with the CLI on a second local drive, not only on network or missing drives. Setup:
codex exec;[windows] sandbox = "elevated"; the sandbox log shows MXC;D:drive;read-onlyorworkspace-write.Output of one command in the sandbox:
Unlike the reports above, the
Ddrive does exist in the PowerShell session. Even so, the provider location and the native child cwd still start atC:\.Consequence under
workspace-write: relative writes go toC:\and are refused (Access to the path 'C:\probe.txt' is denied), so a delegated task cannot write to its worktree.With
-s danger-full-access, the same run starts in the workspace:(Get-Location).Pathis the repository. Reproduced on 4 November 2026.denelon commentedon Nov 5, 2026
A Microsoft MXC issue documents a closely matching PowerShell working-directory mismatch:
Both reports observe that the process-level current directory is set to the requested workspace while PowerShell’s provider location points elsewhere, causing relative paths and native tooling to operate from the wrong directory. The Codex report additionally describes missing filesystem PSDrives and unavailable PowerShell modules, so its full symptom set is broader. The shared split between process cwd and PowerShell provider location suggests the MXC issue may be directly relevant, without establishing that every reported symptom has the same cause.
Drafted with GitHub Copilot assistance.