Repository navigation
[Bug][Windows] pwsh ENOENT obscures a nonexistent working directory #13011
wtwang1998
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
On Windows, when the DSH
pwshtool receives a nonexistentworkdir, it returns an error such as:The message names the PowerShell executable but does not identify the invalid working directory as the cause. This made the failure look like a PowerShell installation or executable-resolution problem.
In the observed case, the supplied path omitted intermediate components of a nested Git worktree path.
Test-Pathconfirmed that the supplied directory did not exist and the actual nested directory did. After using the correct absoluteworkdir, the same DSH tool successfully ran Git commands. This report concerns error diagnostics and recovery, not a broken PowerShell installation.Reproduction
Use a nested worktree whose actual directory is similar to:
Invoke the DSH
pwshtool with the incorrect path, omitting the intermediate components:Run a trivial command such as:
Write-Output OKThe tool returns an executable-oriented
ENOENTerror rather than an explicit invalid-workdirerror.The user independently checked both paths:
With the correct absolute
workdir, the DSH tool subsequently rangit rev-parse --show-topleveland other Git checks successfully.Current behavior
workdirproduces aspawn <path-to-pwsh.exe> ENOENTerror.workdiror indicate whether it exists.Expected behavior
Validate an explicit
workdirbefore spawning the process.If it does not exist or is not accessible, return a clear error such as:
For other process-creation failures, report the resolved executable, requested working directory, underlying OS error, and whether command execution began.
Recovery guidance should help identify the correct existing worktree path. It should not automatically delete or recreate worktrees or alter their contents.
Suggested regression test
Run the same trivial PowerShell command once with an existing absolute directory and once with a nonexistent absolute directory.
This is a suggested test; it has not been added to or run against the DSH codebase.
Environment
10.0.26200, build26200, 64-bit.0.2.2.0and FileVersion0.2.2-rc.1.7.7.0, Microsoft Store/MSIX installation.%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe.Get-Command pwshresolves to%LOCALAPPDATA%\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe.%ProgramFiles%\WindowsApps\Microsoft.PowerShell_7.7.0.0_x64__8wekyb3d8bbwe.shell.pwshPathwas explicitly set to the WindowsApps alias during reproduction.2.53.0.windows.3.2.98.0(2026-08-20).Related reports
run_coderuntime is affected by setting the session cwd to anapp.asarvirtual path (Windows). Related to cwd validation, but a different path failure.pwsh spawn ENOENTafter a Microsoft Store PowerShell update leaves a stale WindowsApps path. That report concerns executable resolution; the present case was caused by a nonexistentworkdirwhile PowerShell itself was available.The nested worktree layout increased the chance of mistyping the path, but this report does not claim DSH created the nested worktree.
All reactions