Skip to content

Windows: launching copilot in a git repo from interactive pwsh kills the parent pwsh.exe (tgrep indexing, 1.0.108) #5404

Open

Description

@kamy-dev

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=false makes 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

  1. Open a PowerShell 7 tab in Windows Terminal (pwsh -NoProfile also reproduces it, so it is not caused by a profile)
  2. cd into a git repository
  3. Run copilot
  4. 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

  1. added theissue type on Nov 10, 2026
  2. added
    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal
    area:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior
    and removed on Nov 10, 2026
  3. WilsonHeres commented on Nov 13, 2026

    @WilsonHeres

    I saw similar behavior with Copilot CLI 1.0.109 on Windows 11 build 26300, PowerShell 7.7.0, and Windows Terminal 1.25.2611.09001.

    Starting copilot in 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=false let Copilot start and run Get-Location in 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.

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

    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminalarea:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions