Repository navigation
Description
Describe the bug
On Windows, launching copilot from an interactive PowerShell 7 session inside a git repository terminates the parent pwsh.exe with an unhandled exception. The Windows Terminal tab closes, and every process attached to that console goes with it (e.g. an ssh-agent started from the shell, so keys have to be re-added).
- Only happens inside a git repository. Outside a git repository, copilot runs normally.
USE_TGREP=falsemakes it go away, so the trigger appears to be the tgrep indexing that 1.0.108 enabled by default ("enable managed shared tgrep indexing by default for eligible repositories").- It started today, right after copilot auto-updated to 1.0.108. I have not yet checked whether 1.0.107 is affected.
The crash itself happens in PSReadLine's key-reader thread in the parent shell: while copilot is running, Console.ReadKey throws InvalidOperationException ("Cannot read keys when either application does not have a console or when console input has been redirected"), and since it is on a background thread with no handler, the whole pwsh process dies. This matches PowerShell/PSReadLine#5197, where console input becomes unavailable for longer than PSReadLine's retry. So something copilot starts for indexing seems to change the state of the console it shares with the parent shell.
Affected version
GitHub Copilot CLI 1.0.108.
Steps to reproduce the behavior
- Open a PowerShell 7 tab in Windows Terminal (
pwsh -NoProfilealso reproduces it, so it is not caused by a profile) cdinto a git repository- Run
copilot - Shortly after copilot starts, pwsh.exe crashes and the tab closes
What I checked:
| Variation | Result |
|---|---|
| Outside a git repository | No crash |
$env:USE_TGREP = 'false'; copilot in a git repository |
No crash |
pwsh -NoProfile, then copilot |
Crash |
Remove-Module PSReadLine, then copilot |
Crash (the reader thread is already running, so this does not remove it) |
Running the real binary directly (%LOCALAPPDATA%\GitHubCopilotCLI\copilot.exe) instead of the VS Code copilot-shim that comes first on PATH |
Crash |
Git's fsmonitor disabled for copilot (GIT_CONFIG_COUNT=1, core.fsmonitor=false) |
Crash (so not caused by git fsmonitor--daemon) |
Workaround: $env:USE_TGREP = 'false' before launching copilot.
Expected behavior
copilot and its helper processes (such as the tgrep indexer) should not change the state of the console that the launching shell is using. Starting copilot in a git repository should never terminate the parent shell.
Additional context
- OS: Windows 11 25H2 (OS Build 26200.9711)
- CPU architecture: <TODO: x86_64 or ARM64>
- Terminal emulator: Windows Terminal
- Shell: PowerShell 7.6.9 (.NET 10.0.14), PSReadLine 2.4.5 (latest on the PowerShell Gallery)
.NET Runtime event (Event ID 1026) written when the tab closes:
Application: pwsh.exe
CoreCLR Version: 10.0.1426.52326
.NET Version: 10.0.14
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
at System.ConsolePal.ReadKey(Boolean intercept)
at Microsoft.PowerShell.Internal.VirtualTerminal._TryIgnoreIOE[T](Func`1 f)
at Microsoft.PowerShell.Internal.VirtualTerminal.ReadKey()
at Microsoft.PowerShell.PSConsoleReadLine.ReadOneOrMoreKeys()
at Microsoft.PowerShell.PSConsoleReadLine.ReadKeyThreadProc()
at System.Threading.Thread.StartHelper.Callback(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Related: PowerShell/PSReadLine#5197 (on the PSReadLine side, an exhausted retry should not kill the host process). I'm reporting it here as well because the trigger is new in copilot 1.0.108.
Activity
WilsonHeres commentedon Nov 13, 2026
I saw similar behavior with Copilot CLI
1.0.109on Windows 11 build 26300, PowerShell 7.7.0, and Windows Terminal 1.25.2611.09001.Starting
copilotin a Git worktree triggered a parent-process-spoofing alert from endpoint protection, and the terminal and shell exited. It also reproduced with the configured MCP servers disabled.Setting
USE_TGREP=falselet Copilot start and runGet-Locationin the same worktree without the alert. I haven't confirmed the underlying cause or whether it's the same as the PSReadLine exception reported above.