[BUG] WSL2: --bg-pty-host injects BROWSER=true into shell sessions, silently breaking all browser-based auth

Resolved 💬 4 comments Opened Jun 3, 2026 by p-clements Closed Jul 11, 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'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

  1. WSL2 Ubuntu 24.04 with wslu installed (wslview at /usr/bin/wslview)
  2. Open a Claude Code terminal session
  3. Run: printenv BROWSER

Output: true

  1. Run any browser-based auth (e.g. aws sso login, Snowflake externalbrowser,

claude auth login)

  1. "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_

View original on GitHub ↗

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