[BUG] WSL2: Repeated powershell.exe calls for USERPROFILE cause ~60s startup delay
Description
When running Claude Code in WSL2, the debug log shows 6+ repeated calls to powershell.exe -Command '$env:USERPROFILE', each taking approximately 10 seconds due to WSL2's slow Windows interop. This adds ~60 seconds of unnecessary startup delay.
Debug Log Evidence
From debug log (~/.claude/debug/*.txt):
2025-12-17T16:31:10.479Z [DEBUG] [SLOW OPERATION DETECTED] execSyncWithDefaults_DEPRECATED (10053.8ms): powershell.exe -Command '$env:USERPROFILE'
2025-12-17T16:31:30.312Z [DEBUG] [SLOW OPERATION DETECTED] execSyncWithDefaults_DEPRECATED (10069.1ms): powershell.exe -Command '$env:USERPROFILE'
2025-12-17T16:31:40.411Z [DEBUG] [SLOW OPERATION DETECTED] execSyncWithDefaults_DEPRECATED (10068.6ms): powershell.exe -Command '$env:USERPROFILE'
2025-12-17T16:31:50.559Z [DEBUG] [SLOW OPERATION DETECTED] execSyncWithDefaults_DEPRECATED (10099.4ms): powershell.exe -Command '$env:USERPROFILE'
2025-12-17T16:32:01.762Z [DEBUG] [SLOW OPERATION DETECTED] execSyncWithDefaults_DEPRECATED (10171.6ms): powershell.exe -Command '$env:USERPROFILE'
2025-12-17T16:32:12.904Z [DEBUG] [SLOW OPERATION DETECTED] execSyncWithDefaults_DEPRECATED (10092.9ms): powershell.exe -Command '$env:USERPROFILE'
Total delay: ~60 seconds just from these redundant calls.
Expected Behavior
The USERPROFILE value should be:
- Cached after the first lookup, OR
- Read from environment variable (
$USERPROFILE) instead of spawning PowerShell, OR - Looked up once at startup and reused
Environment
- Platform: WSL2 on Windows 11
- Claude Code Version: 2.0.71
- Shell: bash
- Linux Distro: Ubuntu (WSL2)
Workaround Attempted
Setting export USERPROFILE="/mnt/c/Users/<username>" in .bashrc does not help because Claude Code explicitly spawns PowerShell rather than reading the environment variable.
Impact
This significantly degrades the user experience for WSL2 users, making Claude Code feel sluggish at startup. WSL2 is a common development environment, especially for users who need Linux tooling on Windows.
Suggested Fix
Cache the USERPROFILE result after the first PowerShell call, or detect WSL and use an alternative method (e.g., parsing /mnt/c/Users/ or reading $USERPROFILE from environment).
4 Comments
Running into this too. Wanted to add some data that might help.
On my setup (Claude 2.0.76, WSL2 2.6.3.0, Win11), I'm seeing the same powershell.exe calls but with different timing - about 700-900ms each instead of 10s. The interesting thing is there are way more of them than I expected: 21 calls in the first ~37 seconds, firing roughly every 1.7 seconds.
From my debug log:
The calls stop after that initial burst, which explains why the sluggishness goes away after ~30-40 seconds. During that window though, there's noticeable typing lag in the input - feels like the sync calls are blocking the UI thread.
Guessing the per-call latency difference (700ms vs 10s) is system-dependent - maybe AV, disk speed, or WSL config. But the redundant calling pattern seems consistent.
Adding another data point from Claude Code 2.0.76 on WSL2:
Environment:
Observations:
Important finding: I have
CLAUDE_CODE_SKIP_WINDOWS_PROFILE=1set and exported in my.bashrc, confirmed active in my environment, but the deprecated code path ignores this flag entirely.Debug log excerpt:
Suggested fix: The
execSyncWithDefaults_DEPRECATEDfunction should check forCLAUDE_CODE_SKIP_WINDOWS_PROFILEbefore spawning PowerShell, or cache the result after the first call.Thanks to @tariq2sa, @bryanm1529, and @TimonKai for identifying this issue!
I encountered a similar problem.
Confirmed Workaround
I can confirm that the following environment variables completely resolve the startup delay in WSL2:
My Environment
Before vs After
| Metric | Before | After |
|--------|--------|-------|
|
Loading skills→Loaded plugins| ~4100ms | ~7ms ||
setup()completion | ~4400ms | ~50ms ||
/statusor/doctoror other command delay | ~2700ms | ~20ms |Key Observation
Before applying the fix, Windows Terminal was significantly slower than VS Code Terminal. After setting these environment variables, both terminals are equally fast.
This suggests that VS Code's
CLAUDE_CODE_ENTRYPOINT=claude-vscodeenvironment may have been partially bypassing this issue, but the root cause (repeatedpowershell.execalls) was still present.Hope this helps other WSL2 users!
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.