[BUG] WSL2: Repeated powershell.exe calls for USERPROFILE cause ~60s startup delay

Resolved 💬 4 comments Opened Dec 17, 2025 by tariq2sa Closed Jan 24, 2026

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:

  1. Cached after the first lookup, OR
  2. Read from environment variable ($USERPROFILE) instead of spawning PowerShell, OR
  3. 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).

View original on GitHub ↗

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