claude-code - 💡(How to fix) Fix [BUG] Extension stuck on "loading models" in WSL when ~/.bashrc contains blocking commands (bash -lic PATH probe hangs indefinitely) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49583Fetched 2026-04-17 08:37:03
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×5

Error Message

The Claude Code VS Code extension hangs indefinitely on "loading models" in WSL2 environments when the user's ~/.bashrc contains any blocking command (typically sudo without NOPASSWD, but any command waiting on /dev/tty triggers it). No error is shown to the user — the webview loads, but /model never responds, prompts get no reply, and "Open new tab" does nothing.

  • A clear error appears in the webview indicating the environment probe timed out and suggesting the user check shell rc files.

Root Cause

-l (login) + -i (interactive) sources ~/.bashrc. When .bashrc contains sudo <cmd> without NOPASSWD, sudo opens /dev/tty to prompt for the password. Under Node-spawned bash there is no TTY, so sudo blocks forever. The extension never receives the probe output and never spawns the claude native binary.

Fix Action

Fix / Workaround

Workaround (user-side)

Code Example

sudo service mysql start > /dev/null 2>&1

---

ps -eo pid,etime,cmd | grep extensionHost | grep -v grep
pstree -p <PID>

---

# Before:
sudo service mysql start > /dev/null 2>&1

# After:
[ -t 0 ] && [ -t 1 ] && sudo service mysql start > /dev/null 2>&1
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report
  • I am using the latest version of Claude Code

What's Wrong?

The Claude Code VS Code extension hangs indefinitely on "loading models" in WSL2 environments when the user's ~/.bashrc contains any blocking command (typically sudo without NOPASSWD, but any command waiting on /dev/tty triggers it). No error is shown to the user — the webview loads, but /model never responds, prompts get no reply, and "Open new tab" does nothing.

The extension spawns bash -lic at activation to probe the user's PATH. Confirmed by grepping extension.js from the installed extension bundle — the literal string printenv PATH is present. This probe inherits the user's ~/.bashrc, and if any line in .bashrc blocks waiting for input, the probe never returns and the claude native binary is never spawned.

This does not happen on VS Code native Windows (no .bashrc to source).

Environment

  • OS: Windows 11 Insider Canary build 26200
  • WSL: WSL2, Ubuntu 24.04.3 LTS (noble)
  • Kernel: Linux 6.6.114.1-microsoft-standard-WSL2 x86_64
  • VS Code: 1.115.0 (commit 41dd792b5e652393e7787322889ed5fdc58bd75b, x64)
  • Node (in vscode-server): v20.20.1
  • Claude Code extension: 2.1.112
  • Remote-WSL extension: 0.99.0

Steps to Reproduce

  1. Use VS Code with Remote-WSL on a WSL2 Ubuntu install.
  2. Add a blocking command to ~/.bashrc, e.g.:
    sudo service mysql start > /dev/null 2>&1
    (any sudo without NOPASSWD, or read, or ssh with passphrase prompt, reproduces it)
  3. Open VS Code, connect to WSL, open the Claude Code panel.
  4. Observe: webview loads, "loading models" spinner runs forever. /model doesn't respond. Sending a prompt produces nothing.
  5. Extension Host log (Anthropic.claude-code) stops at launch_claude with no further lines.

Expected Behavior

Either:

  • The PATH probe times out after a reasonable window (5-10 s) and falls back to the parent process PATH, OR
  • A clear error appears in the webview indicating the environment probe timed out and suggesting the user check shell rc files.

Root Cause Analysis

-l (login) + -i (interactive) sources ~/.bashrc. When .bashrc contains sudo <cmd> without NOPASSWD, sudo opens /dev/tty to prompt for the password. Under Node-spawned bash there is no TTY, so sudo blocks forever. The extension never receives the probe output and never spawns the claude native binary.

Diagnosis (how to confirm)

In a real WSL terminal (not the broken VS Code session):

ps -eo pid,etime,cmd | grep extensionHost | grep -v grep
pstree -p <PID>

Telltale signature: no claude(...) child under the extensionHost, and instead a bash->sudo chain hanging off it.

Workaround (user-side)

Wrap blocking .bashrc lines in a TTY check:

# Before:
sudo service mysql start > /dev/null 2>&1

# After:
[ -t 0 ] && [ -t 1 ] && sudo service mysql start > /dev/null 2>&1

Then kill the stuck bash/sudo processes and Developer: Reload Window. Extension works immediately.

Suggested Fixes (extension-side)

  1. Timeout on the PATH probe — abort bash -lic after N seconds and fall back to the parent process PATH.
  2. Surface feedback in the webview when the probe times out.
  3. Log the probe command and duration in the extension log.
  4. Document in troubleshooting that WSL users with .bashrc blocking commands may hit this.

Additional Notes

This was initially misdiagnosed as a version compatibility issue (pin to 2.1.77 appeared to "work"). It was not — 2.1.77 simply predated the addition of the blocking command to .bashrc. The bug reproduces on all versions that contain the printenv PATH probe.

extent analysis

TL;DR

The most likely fix is to implement a timeout on the PATH probe in the Claude Code extension to prevent it from hanging indefinitely when encountering blocking commands in the user's ~/.bashrc.

Guidance

  • To verify the issue, check the Extension Host log for the Anthropic.claude-code and look for the launch_claude entry with no further lines, indicating the probe has timed out.
  • To mitigate the issue, users can wrap blocking .bashrc lines in a TTY check, such as [ -t 0 ] && [ -t 1 ] && sudo service mysql start > /dev/null 2>&1, to prevent the probe from hanging.
  • The extension can be modified to log the probe command and duration to help diagnose the issue.
  • Implementing a timeout on the PATH probe, such as 5-10 seconds, can prevent the extension from hanging indefinitely.

Example

# Before:
sudo service mysql start > /dev/null 2>&1

# After:
[ -t 0 ] && [ -t 1 ] && sudo service mysql start > /dev/null 2>&1

Notes

The issue is specific to WSL2 environments and is caused by the bash -lic probe inheriting the user's ~/.bashrc and blocking on commands that wait for input. The suggested fixes focus on modifying the extension to handle this scenario.

Recommendation

Apply a workaround by wrapping blocking .bashrc lines in a TTY check, and consider implementing a timeout on the PATH probe in the extension to prevent similar issues in the future. This approach allows users to continue using the extension while the underlying issue is addressed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Extension stuck on "loading models" in WSL when ~/.bashrc contains blocking commands (bash -lic PATH probe hangs indefinitely) [1 participants]