anthropics / anthropics/claude-code
[BUG] Windows: `claude auth login` / OAuth browser doesn't open automatically in Git Bash — no fallback to cmd.exe /c start (regression since 2.1.141)
- Langage dominant
- Python
- Étoiles
- 145k
- Forks
- 23.1k
- Métriques de merge des PR
- Métriques de PR en attente
Description
### Preflight Checklist
- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) 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?
On Windows, `claude auth login` (and any other OAuth flow driven by the CLI, e.g. `/mcp` authentication) does not open the default browser automatically when running from a Git Bash (MSYS2/MINGW64) shell. The command prints the login URL and device code, and the user has to copy-paste them by hand.
This used to work — the browser opened automatically in earlier versions. It broke as a regression starting with v2.1.141 (auto-update, 2026-05-14): the browser-open logic changed and, in a Git Bash session where `BROWSER` and `DISPLAY` are unset, there is no fallback to `cmd.exe /c start` anymore. The equivalent issue for MCP auth in the same environment (#59194) documents the same regression and root cause, but was auto-closed as stale/"not planned" without a fix; the underlying `claude auth login` case (not just MCP) is still broken.
### What Should Happen?
On Windows, when `BROWSER` is unset and there's no `DISPLAY` (i.e. a normal Git Bash session, not X11), the CLI should fall back to `cmd.exe /c start "" ` (or an equivalent native Windows browser-open call), the same way it apparently did before v2.1.141, instead of silently doing nothing and leaving the user to copy-paste the URL by hand.
### Error Messages/Logs
```shell
No error is printed — the CLI prints the OAuth URL and device code as normal and waits for the code, it just never spawns a browser process. Confirmed via Task Manager: no new browser process appears after running `claude auth login`.
```
### Steps to Reproduce
1. On Windows, open Git Bash (MINGW64) — the default shell bundled with Git for Windows.
2. Do not set a `BROWSER` environment variable.
3. Run `claude auth login`.
4. Expected: the default browser (Chrome, correctly registered as the Windows default handler for http/https on this machine) opens automatically to the OAuth URL.
5. Actual: nothing opens. The CLI prints the URL and code and waits; the user has to copy the URL into a browser by hand and then copy the resulting code back into the terminal.
6. Workaround that restores the old behavior: add `{ "env": { "BROWSER": "cmd.exe /c start \"\"" } }` to `~/.claude/settings.json`, as documented in the comments on #59194. This should not be necessary — it worked with zero configuration before v2.1.141.
### Claude Model
None
### Is this a regression?
Yes, this worked in a previous version
### Last Working Version
2.1.139
### Claude Code Version
2.1.237 (Claude Code)
### Platform
Anthropic API
### Operating System
Windows
### Terminal/Shell
Other
### Additional Information
This is the `claude auth login` / general OAuth-CLI-flow instance of the exact regression described in #59194 ("OAuth browser does not open for HTTP MCP servers on Windows"), which was auto-closed as stale/"not planned" in June without a fix. Filing separately since #59194 is closed and the underlying regression (no `cmd.exe` fallback since 2.1.141 in a Git-Bash/no-DISPLAY environment) is still present for at least the `claude auth login` flow, not just MCP auth. Also closed/related: #44350 (dup), #30902 (dup).
Workaround for anyone hitting this in the meantime: `~/.claude/settings.json` → `{ "env": { "BROWSER": "cmd.exe /c start \"\"" } }` (the empty quotes after `start` are required — that's the window-title argument `start` expects). Would be good if this became the default behavior on Windows again rather than something every affected user has to independently discover and configure by hand.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Start by reproducing `claude auth login` in Windows Git Bash with `BROWSER` and `DISPLAY` unset, then trace the CLI's OAuth browser-opening path and its Windows handling. Done means the default browser opens automatically through a native Windows fallback, while the existing login URL and code flow still work.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- bash, python
- Domaine
- authentication, cli, operating-systems
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 55/100