[BUG] WSL2: --bg-pty-host injects BROWSER=true into shell sessions, silently breaking all browser-based auth
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's --bg-pty-host process injects BROWSER=true into the environment of
every shell session it manages. On WSL2 this silently breaks all browser-based auth
flows (Claude Code's own OAuth login, AWS SSO, Snowflake externalbrowser, etc.)
because BROWSER=true causes xdg-open (wslu) to invoke the shell built-in true
as the "browser" command — which exits 0 without opening anything.
Process tree evidence (via /proc/<pid>/environ):
claude daemon run → BROWSER not set
claude --bg-pty-host → BROWSER=true ← introduced here
claude --bg-spare → BROWSER=true (inherited)
user shell → BROWSER=true (inherited)
BROWSER=true is not set anywhere in user shell config files (.zshrc, .zshenv,
/etc/environment, ~/.config/environment.d/, systemd user environment). It is
exclusively injected by the Claude Code PTY host.
What Should Happen?
--bg-pty-host should not inject BROWSER=true into user shell session environments. On WSL2, xdg-open (wslu v4.1.3) correctly bridges to Windows via wslview when BROWSER is unset. BROWSER=true silently breaks this.
Error Messages/Logs
Steps to Reproduce
- WSL2 Ubuntu 24.04 with wslu installed (wslview at /usr/bin/wslview)
- Open a Claude Code terminal session
- Run: printenv BROWSER
Output: true
- Run any browser-based auth (e.g. aws sso login, Snowflake externalbrowser,
claude auth login)
- "Attempting to open browser" message appears but no window opens; process
hangs indefinitely waiting for OAuth callback
Confirm the injection source:
PHOST=$(pgrep -f "claude --bg-pty-host")
cat /proc/$PHOST/environ | tr '\0' '\n' | grep BROWSER # → BROWSER=true
DAEMON=$(pgrep -f "claude daemon run")
cat /proc/$DAEMON/environ | tr '\0' '\n' | grep BROWSER # → (empty)
Workaround: add export BROWSER=wslview to ~/.zshrc
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.158
Claude Code Version
2.1.161
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗