WSL2 az login xdg-open and Microsoft Edge (or any other browser)
If you ever run into a problem with az login opening a Windows browserto complete the login, this blog post may help. I ran into this today.When I did az logout followed by az login I saw the following, andthe login did not complete succesfully.
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: firefox: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: iceweasel: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: seamonkey: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: mozilla: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: epiphany: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: konqueror: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium-browser: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: google-chrome: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: www-browser: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links2: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: elinks: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: lynx: not found/usr/bin/xdg-open: 851: /usr/bin/xdg-open: w3m: not foundxdg-open: no method available for opening 'https://login.microsoftonline.com/com...'I thought:
��\_(���)_/��After poking around a bit, I arrived at the following solution.
1. Make an executable script in my bin directory that runs the browser on the windows sideSee step 5 in my previous post.Modify the script to reference your preferred browser.
2. Create an edge.desktop file in the correct placeMake it so this file exists: ~/.local/share/applications/edge.desktopand has the following content.
[Desktop Entry]Encoding=UTF-8Version=1.0Type=ApplicationNoDisplay=trueExec=/home/edburns/bin/runedge.sh %uName=EdgeComment=Custom definition for Edge BetaYou���ll need to modify the value of the Exec line accordingly. Also,if you are using a different browser, you���ll need to change the name ofthe file to whaterYourBrowser.desktop. Close the file when done editing.
3. Use xdg-settings to set the default-web-browserNow that you have created edge.desktop in the correct place, you cantell xdg-settings that it is the default browser.
xdg-settings set default-web-browser edge.desktopThe first time I ran this, it took a while, and I observed it added thisline to the edge.desktop file.
MimeType=x-scheme-handler/unknown;x-scheme-handler/about;x-scheme-handler/https;x-scheme-handler/http;text/html;You can verify the setting with the following command.
xdg-settings get default-web-browser4. az login should pop up the browser.az logoutaz login

