Open weikanglim opened 1 year ago
@weikanglim +1 for WSL experience
Just tried this. Works smooth in codespaces. Should be like that in WSL too.
@pdebruin are you getting an error in WSL? Can you share it?
This would be a common scenario for devcontainers without xdg-utils installed.
@weikanglim we should update azd to use https://github.com/pkg/browser
for opening a browser. This is what msal is using for interactive login. It would give us 2 more providers on linux:
func openBrowser(url string) error {
providers := []string{"xdg-open", "x-www-browser", "www-browser"}
// There are multiple possible providers to open a browser on linux
// One of them is xdg-open, another is x-www-browser, then there's www-browser, etc.
// Look for one that exists and run it
for _, provider := range providers {
if _, err := exec.LookPath(provider); err == nil {
return runCmd(provider, url)
}
}
return &exec.Error{Name: strings.Join(providers, ","), Err: exec.ErrNotFound}
}
Moving to https://github.com/pkg/browser
will also help us during cloudshell interactive login
@vhvb1989 Do you see a custom usage in azd
somewhere? IIRC, we are relying on msal, which in turn relies on pkg/browser.
@pdebruin are you getting an error in WSL? Can you share it?
=== Yes, see below:
$ azd init --template todo-java-mongo-aca
Initializing a new project (azd init)
(✓) Done: Initialized git repository (✓) Done: Downloading template code to: ~/_projects/azdwsl2
? Please enter a new environment name: azdwsl2-dev
SUCCESS: New project initialized! You can view the template code in your directory: ~/_projects/azdwsl2 Learn more about running 3rd party code on our DevHub: https://learn.microsoft.com/azure/developer/azure-developer-cli/azd-templates#guidelines-for-using-azd-templates
$ azd up
Error: not logged in, run azd auth login
to login
$ azd auth login
/usr/bin/xdg-open: 882: x-www-browser: not found
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: iceweasel: not found
/usr/bin/xdg-open: 882: seamonkey: not found
/usr/bin/xdg-open: 882: mozilla: not found
/usr/bin/xdg-open: 882: epiphany: not found
/usr/bin/xdg-open: 882: konqueror: not found
/usr/bin/xdg-open: 882: chromium: not found
/usr/bin/xdg-open: 882: chromium-browser: not found
/usr/bin/xdg-open: 882: google-chrome: not found
/usr/bin/xdg-open: 882: www-browser: not found
/usr/bin/xdg-open: 882: links2: not found
/usr/bin/xdg-open: 882: elinks: not found
/usr/bin/xdg-open: 882: links: not found
/usr/bin/xdg-open: 882: lynx: not found
/usr/bin/xdg-open: 882: w3m: not found
xdg-open: no method available for opening 'https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=
ERROR: logging in: exit status 3
=== Tried to repro on second machine, which responded with
ERROR: logging in: exec: "xdg-open,x-www-browser,www-browser": executable file not found in $PATH
===
Hope that helps
Congrats on the release! 🎉 For completeness, anyone visiting this issue should get azd in wsl to work using: azd auth login --use-device-code azd auth login --check-status
@vhvb1989 Was WSL working with interactive browser?
Yes, it works, but it depends on xdg-open + BROWSER
config or on installing wslu (https://github.com/wslutilities/wslu)
Also related: https://github.com/Azure/azure-dev/issues/2291
@weikanglim @vhvb1989 is this issue still valid with @ellismg MSAL changes to override the package used for browser opening? - https://github.com/Azure/azure-dev/issues/2291#issuecomment-1561666398
Apparently this isn't yet solved.
Today I came across a similar issue (https://github.com/Azure-Samples/azure-search-openai-demo/issues/1855) executing azd auth login
from a GitHub codespace terminal.
As suggested here (https://github.com/Azure/azure-cli/issues/20315) azd auth login --use-device-code
solved the issue.
Currently,
azd login
fails with the following error if no browser is installed on Linux:This would be a common scenario for devcontainers without
xdg-utils
installed.We should either fallback to device code login or provide user hints to try device code login as a fallback.