Windows: rg.exe processes never terminated, blocking app updates (file locked)
Summary
The Claude Code extension spawns persistent rg.exe (ripgrep) processes on Windows for codebase indexing/search and never terminates them. These processes hold file locks on rg.exe inside the app's install directory, preventing the app's updater (Squirrel.Windows) from replacing the binary during an update. The update fails and leaves the app in a broken state requiring full reinstall.
Root Cause
Claude Code uses ripgrep (@vscode/ripgrep) for codebase search. On Windows, a running process holds an exclusive kernel-level file lock on its own executable — unlike Linux where deletion of a running binary is allowed.
Claude Code does not terminate spawned rg.exe child processes:
- When the search/indexing task completes
- When the editor window loses focus
- On the extension
deactivate()lifecycle hook - Before the Electron app emits
before-quit
Steps to Reproduce
- Install Claude Code extension in any VSCode-based Electron editor on Windows (Cursor, VS Code, etc.)
- Open a project and let Claude Code index/search the codebase
- Observe multiple
rg.exeprocesses in Task Manager — they remain after search completes - Trigger an app update while the editor is open
- Expected: Update succeeds
- Actual: Update fails —
"this action can't be completed because the file is open in rg"
Evidence
- Observed 3+ simultaneous
rg.exeprocesses per editor instance, unkillable viaStop-Processwhile the parent app is running - Community confirmation via VSCode Extension Bisect (devcontainer/Ubuntu, same symptom — dozens of rg processes, resolved by disabling Claude Code extension)
- Affects all VSCode-based Electron apps on Windows that bundle ripgrep
Environment
- OS: Windows 11 (10.0.26200.7840)
- Affected apps: Cursor, any VSCode-based Electron app with Claude Code extension
- Claude Code version: latest
Workaround (for users)
# Fully quit the editor first, then update
# Or kill rg before updating:
Stop-Process -Name "rg" -Force
Fix Recommendation
Claude Code extension should terminate all spawned rg.exe child processes:
- When the search/indexing task completes (primary fix)
- In the
deactivate()extension lifecycle hook - On Electron
before-quitevent
// Example in extension deactivate()
export function deactivate() {
rgProcesses.forEach(proc => proc.kill());
rgProcesses.clear();
}
This fix would also resolve the related issue of rg process proliferation in devcontainers on Linux (same root cause: processes not cleaned up after use).
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗