azure-cli: az login WSL 2 Ubuntu 18.04 does not open browser: Detect no GUI is available, so fall back to device code
Describe the bug
When running command az login
web browser won’t open.
Running on verbose mode
az login --verbose
Detect no GUI is available, so fall back to device code
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code GFHKIOWYA to authenticate.
To Reproduce
Run az login
on WSL 2 Ubuntu 18.04
Expected behavior Default browser opens on AZ login page.
Environment summary Windows 10 Pro 2004
WSL 2 Ubuntu 18.04
uname -a
Linux MY-COMPUTER 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
az --version
azure-cli 2.10.0
command-modules-nspkg 2.0.3
core 2.10.0
nspkg 3.0.4
telemetry 1.0.4
Python location '/opt/az/bin/python3'
Extensions directory '/home/nico/.azure/cliextensions'
Python (Linux) 3.6.10 (default, Jul 31 2020, 08:33:11)
[GCC 7.5.0]
Additional context Running
powershell.exe -Command 'Start-Process https://github.com/Azure/azure-cli/issues'
opens successfully the browser on the Azure CLI issues page.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 16 (7 by maintainers)
We currently haven’t developed and tested on WSL 2, so it is not supported yet. For now, you may use
Just use below - its Display issue DISPLAY=:0 az login
Let me reopen it and put it into our roadmap.
@schundu9, setting
DISPLAY=:0
is basically hacking into this linehttps://github.com/Azure/azure-cli/blob/25912fdf933a960babd006ebe40b71548ab89b41/src/azure-cli-core/azure/cli/core/util.py#L692
to force env var
DISPLAY
to exist and trick Azure CLI that it is run in a Linux desktop environment.Not only
:0
works, but anything works, likeDISPLAY=foo az login
.However, it will trigger a warning:
⚠ This is not the supported way to launch browser in WSL 2.