AzureAD/microsoft-authentication-cli

Install fails if PATH variable is > 1024 characters.

seanadams9 opened this issue · 6 comments

PS C:\Users\seadams> $env:AZUREAUTH_VERSION = '0.6.0'
PS C:\Users\seadams> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS C:\Users\seadams> iex "& { $(irm https://raw.githubusercontent.com/AzureAD/microsoft-authentication-cli/${env:AZUREAUTH_VERSION}/install/install.ps1) } -Verbose"
VERBOSE: Installing using post-0.4.0 method
VERBOSE: Creating C:\Users\seadams\AppData\Local\Programs\AzureAuth
VERBOSE: Downloading
https://github.com/AzureAD/microsoft-authentication-cli/releases/download/0.6.0/azureauth-0.6.0-win10-x64.zip to
C:\Users\seadams\AppData\Local\Programs\AzureAuth\azureauth-0.6.0-win10-x64.zip
VERBOSE: Extracting C:\Users\seadams\AppData\Local\Programs\AzureAuth\azureauth-0.6.0-win10-x64.zip to
C:\Users\seadams\AppData\Local\Programs\AzureAuth\0.6.0
VERBOSE: Removing C:\Users\seadams\AppData\Local\Programs\AzureAuth\azureauth-0.6.0-win10-x64.zip
VERBOSE: Appending 'C:\Users\seadams\AppData\Local\Programs\AzureAuth\0.6.0' to $env:PATH

WARNING: The data being saved is truncated to 1024 characters.
Installed azureauth 0.6.0!

setx truncates the path to 1024 characters, opening a new shell "azureauth" isn't found on the path
. https://superuser.com/questions/387619/overcoming-the-1024-character-limit-with-setx

Thanks for the report, @seanadams9. We'll look into this right away.

FYI, using setx was a deliberate choice because of these properties.

# Update the $PATH environment variable with any modifications made above. We use `setx` here instead of
# directly writing back the registry value because `setx` signals new processes to pick up on the environment
# variable changes.
setx PATH $newPath > $null

I'm not sure we were aware of or accounted for the truncation at the time...

For further clarity, the desired property is the broadcast of the WM_SETTINGCHANGE message. I think that we can set the $PATH through direct registry manipulation ourselves and then broadcast that message ourselves, but it's more complicated in PowerShell than just using setx. We'll have to dig into how to do that... 😅

Can you not just use powershell via:

[Environment]::SetEnvironmentVariable('PATH',$newPath, [System.EnvironmentVariableTarget]::User)

I might be mistaken, but I don't believe that will propagate the environment variable change to new processes, just the current PowerShell or Windows Terminal window. I would be happy to be wrong though.

More precisely, I don't think that can have an effect on processes that aren't PowerShell and we also have users launching azureauth entirely outside PowerShell. Again, would love to be wrong though.