[BUG] WSL2: session freezes every ~1s for first 30s on startup — powershell.exe spawned 38 times to resolve USERPROFILE

Resolved 💬 3 comments Opened Feb 28, 2026 by zachleach Closed Mar 29, 2026

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?

Claude Code has severe input lag for ~30 seconds on every startup when running on WSL2. The input freezes every ~1 second then catches up in bursts. During this window, Claude Code is spawning powershell.exe -Command '$env:USERPROFILE' approximately 38 times to resolve the Windows home directory. Each powershell.exe launch takes ~700ms due to WSL interop overhead, blocking the Node.js event loop and causing the stutter. The result is never cached between calls.

What Should Happen?

Claude Code should check for USERPROFILE in the environment before shelling out to powershell. If it must call powershell, it should do it once and cache the result — not 38 times during startup.

Error Messages/Logs

No error messages. Diagnosed via strace:


strace -f -T -o /tmp/strace_startup.log claude


Key findings from the trace:

- 38 `powershell.exe` invocations during startup, each taking ~600-800ms
- 19 `wslpath` invocations to convert the returned Windows path
- Main thread `epoll_pwait2` blocks of 500-800ms corresponding to each powershell spawn
- Total accumulated blocking: ~27 seconds

Example subprocess chain from the trace:

execve("/bin/sh", ["/bin/sh", "-c", "powershell.exe -Command '$env:USERPROFILE'..."])
execve("/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0//powershell.exe", ["powershell.exe", "-Command", "$env:USERPROFILE"])
execve("/usr/bin/wslpath", ["wslpath", "-u", "C:\\Users\\lacht"])


This pattern repeats 38 times during the first 30 seconds of startup.

Steps to Reproduce

  1. Run Claude Code on WSL2 (tested on Ubuntu, WSL2 kernel 6.6.87.2)
  2. Make sure USERPROFILE is not set in your shell environment (this is the default on WSL)
  3. Start Claude Code: claude
  4. Hold down any key — observe the input freezing every ~1s for approximately 30 seconds

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.50 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

Workaround: Pre-set the USERPROFILE environment variable so Claude Code never shells out to powershell:

# Add to ~/.bashrc
export USERPROFILE="/mnt/c/Users/YOUR_WINDOWS_USERNAME"

Environment:

  • WSL2, kernel 6.6.87.2-microsoft-standard-WSL2
  • Claude Code installed via install.sh (stable channel)
  • Node v22.21.1

Suggested fix: In the codebase, wherever powershell.exe -Command '$env:USERPROFILE' is called:

  1. Check process.env.USERPROFILE first and use it if set
  2. If not set, call powershell once, cache the result, and set process.env.USERPROFILE for subsequent calls

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗