Windows corporate environment: Infinite EPERM retry loop with SessionStart hooks
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment
- OS: Windows 10/11 (corporate environment with GPO policies)
- Claude Code CLI: v2.0.31
- User: Administrator
- Location: C:\Users\[corporate-user]\.claude.json
Root Cause
Corporate GPO policies block creation of .claude.json.lock directory → EPERM error
CLI behavior:
- Attempts atomic write with lock → EPERM
- Falls back to non-atomic write → SUCCESS ✓
- BUG: Continues retrying atomic write infinitely (no backoff, no limit)
- Event loop blocked → stdin frozen
What Should Happen?
Expected Behavior
After fallback succeeds, CLI should:
- Stop retrying atomic write
- Return success
- Not block event loop
Logs
[ERROR] Failed to save config with lock: EPERM [DEBUG] Falling back to non-atomic write [DEBUG] File written successfully with fallback [ERROR] Failed to save config with lock: EPERM ← REPEATS 20+ TIMES
Impact
- Affects Windows corporate environments with restrictive GPOs
- Only occurs in repos WITH SessionStart hooks
- Repos without hooks work normally
- Makes Claude Code CLI unusable in corporate settings
Suggested Fixes
- Stop retrying after successful fallback (critical)
- Add exponential backoff (max 3 retries)
- Add config option:
"disableFileLocking": true - Detect corporate environment and
Error Messages/Logs
## Logs
[ERROR] Failed to save config with lock: EPERM [DEBUG] Falling back to non-atomic write [DEBUG] File written successfully with fallback [ERROR] Failed to save config with lock: EPERM ← REPEATS 20+ TIMES
Steps to Reproduce
Reproduction
- Configure SessionStart hooks in
.claude/settings.json - Launch
claudein project directory (Windows corporate environment) - Hooks execute successfully (JSON output validates)
- CLI freezes - stdin becomes unresponsive
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.0.31
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Happened every single time i tried session start hooks. Went through a thorough process of permission corrections and basically rebuilt (was running powershell as admin, a whole lotta fjckery with file property etc.
But now I really did pay attention. The hooks WORK in powershell normally. Other repos (with no session start hooks) also work.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗