-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Profile} az login: In WSL use powershell.exe to open the default browser #12851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
add to S168 |
| return subprocess.call(['cmd.exe', '/c', "start {}".format(url.replace('&', '^&'))]) | ||
| # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe | ||
| # Ampersand (&) should be quoted | ||
| return subprocess.call(['powershell.exe', '-Command', 'Start-Process "{}"'.format(url)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without double quote, powershell.exe gives error:
# WSL
$ powershell.exe -Command 'Start-Process https://github.com/?a=1&b=2'
At line:1 char:38
+ Start-Process https://github.com/?a=1&b=2
+ ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : AmpersandNotAllowedThis works:
$ powershell.exe -Command 'Start-Process "https://github.com/?a=1&b=2"'There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, is it a powershell executable inside WSL?
|
@GarrettGeorge, do you mind also doing a quick test on whether this works for you? |
qianwens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
Description
Fix #11927: az login uses
cmd.exewhen using WSL which doesn't support UNC pathsaz loginin WSL shows warning:This can also be reproduced by running
cmd.exedirectly in WSL:powershell.exeon the other hand doesn't have this problem and can handle UNC paths correctly:This PR removes the UNC path warning by calling
powershell.exeinstead ofcmd.exeto open the browser.Testing Guide
Use either method:
Install Azure CLI in WSL from source
Install Azure CLI in WSL with apt
Follow Install Azure CLI with apt. Then replace
C:\Users\{username}\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\opt\az\lib\python3.6\site-packages\azure\cli\core\util.pywith theutil.pyfile in this PR.Then run
az login. The warning is gone.