microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
23.08k stars 1.44k forks source link

'winget install' does not (properly, or at all) expand paths on Windows 11, builds 22449 through latest. #1435

Closed fkelava closed 3 years ago

fkelava commented 3 years ago

Brief description of your issue

winget install fails to expand paths when encountering user profiles with a name longer than 8 characters. Specifically, a call to std::filesystem::rename will fail. A trigger may also be a space or dot, or any other special character in the user profile path.

A notable example of the latter are accounts provisioned from Azure AD, as these commonly take the form of NameSurname, not normalizing special characters, e.g. IvoIvić, or name.surname, e.g. fran.kelava.

Steps to reproduce

This is perfectly reproducible using any package. You do not need to use the exact package from the example.

During your Windows install, sign in with an MSA/AAD account. Your resulting user directory name may include special characters or a dot separating your name and surname, and this must be the case to trigger this issue. OR During your Windows install, skip MSA/AAD login and create a local account longer than 8 characters in length, and add a space in it for good measure.

PS C:\Users\fran.kelava> winget install 'voidtools.EverythingLite'

Expected behavior

The command throws no error.

Actual behavior

PS C:\Users\fran.kelava> winget install 'voidtools.EverythingLite'
Found Everything Lite [voidtools.EverythingLite]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://www.voidtools.com/Everything-1.4.1.1009.x64.Lite.msi
  ██████████████████████████████  1.67 MB / 1.67 MB
Successfully verified installer hash
An unexpected error occurred while executing the command:
rename: The system cannot find the file specified.: "C:\Users\FRAN~1.KEL\AppData\Local\Temp\WinGet\voidtools.EverythingLite.1.4.1.1009", "C:\Users\FRAN~1.KEL\AppData\Local\Temp\WinGet\voidtools.EverythingLite.1.4.1.1009.msi"

This may also be related to the problem showcased in #1203, in which an AAD-based account suffered a similar or identical issue. While the author of that issue also had special characters making the issue more difficult, the issue also plainly appears for usernames which do not feature special characters.

In #1203, the issue author saw functionality restored once the dot and special characters were eliminated from the user directory name. [UPDATE] However, based on the replies below, it seems that this is an issue with path expansion in general.

However, I'm afraid I must insist that this issue be properly fixed. It is not acceptable for winget to ship broken by default in instances where the user cannot influence the name of their user directory, e.g. Azure AD joins in OOBE.

Environment

Windows Package Manager v1.0.11694
Windows: Windows.Desktop v10.0.22449.1000
Package: Microsoft.DesktopAppInstaller v1.15.11694.0

This is a clean install of the latest Dev Channel Insiders build at the time of posting.
fkelava commented 3 years ago

Here's the relevant log, this time for a Notepad++ install.

WinGet-2021-09-05-17-27-33.910.log

Note the relevant segment:

2021-09-05 17:27:36.490 [FAIL] E:\BA\98\s\external\pkg\src\AppInstallerCLICore\Workflows\ShellExecuteInstallerHandler.cpp(269)\AppInstallerCLI.exe!00007FF7B59D2F01: (caller: 00007FF7B58520B0) LogHr(1) tid(22c8) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: rename: The system cannot find the file specified.: "C:\Users\FRAN~1.KEL\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4", "C:\Users\FRAN~1.KEL\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4.exe"] 

2021-09-05 17:27:36.745 [CLI ] Caught std::exception: rename: The system cannot find the file specified.: "C:\Users\FRAN~1.KEL\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4", "C:\Users\FRAN~1.KEL\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4.exe"

This makes no sense, as

PS C:\Users\fran.kelava> ren 'C:\Users\fran.kelava\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4' 'C:\Users\fran.kelava\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4.exe'

and

PS C:\Users\fran.kelava> ren 'C:\Users\FRAN~1.KEL\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4' 'C:\Users\FRAN~1.KEL\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4.exe'

can be performed successfully.

fkelava commented 3 years ago

This can be traced down to some behavior of std::filesystem::rename, the faulting point is https://github.com/microsoft/winget-cli/blob/master/src/AppInstallerCLICore/Workflows/ShellExecuteInstallerHandler.cpp#L266.

I don't have any experience with C++ and consequently do not know what the specifics of the call are and why it would throw in this instance.

oleksis commented 3 years ago

i get error about rename the program downloaded:

➜ winget install GnuWin32.Make
Found GnuWin32: Make [GnuWin32.Make]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://sourceforge.net/projects/gnuwin32/files/make/3.81/make-3.81.exe/download
  ██████████████████████████████  3.22 MB / 3.22 MB
Successfully verified installer hash
An unexpected error occurred while executing the command:
rename: The system cannot find the file specified.: "C:\Users\USER~1.HP~\AppData\Local\Temp\WinGet\GnuWin32.Make.3.81", "C:\Users\USER~1.HP~\AppData\Local\Temp\WinGet\GnuWin32.Make.3.81.exe"
jedieaston commented 3 years ago

This doesn't seem to just be if you have special characters in your name. I'm running from the local administrator account:

image

The last few lines of the log file:

The exception %s (0x    Msg:[std::exception: rename: The system cannot find the file specified.: "C:\Users\ADMINI~1\AppData\Local\Temp\WinGet\Mozilla.Firefox.92.0", "C:\Users\ADMINI~1\AppData\Local\Temp\WinGet\Mozilla.Firefox.92.0.msi"] 

2021-09-13 09:12:23.632 [CLI ] Caught std::exception: rename: The system cannot find the file specified.: "C:\Users\ADMINI~1\AppData\Local\Temp\WinGet\Mozilla.Firefox.92.0", "C:\Users\ADMINI~1\AppData\Local\Temp\WinGet\Mozilla.Firefox.92.0.msi"
PS C:\Users\Administrator> winget --info
Windows Package Manager v1.0.11694
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22454.1000
Package: Microsoft.DesktopAppInstaller v1.15.11694.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

Links
--------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget

I wonder if this is something wrong with the latest Insider Fast build and not with winget.

Masamune3210 commented 3 years ago

Works fine for me on latest, it looks like for some reason that the Admini~1 isn't being expanded by either winget or the system for some reason is my guess

fkelava commented 3 years ago

@jedieaston This issue persists for me through a few Insider builds now. If they've been broken, they've been broken for a while now, which might be possible but seems unlikely. Considering a normal "ren" will expand the path correctly, I'm inclined to think it's not the OS.

jedieaston commented 3 years ago

This is the first build it was broken for me, weird. Must be a winget thing though.

oleksis commented 3 years ago

i get error about rename the program downloaded:


➜ winget install GnuWin32.Make

Found GnuWin32: Make [GnuWin32.Make]

This application is licensed to you by its owner.

Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.

Downloading https://sourceforge.net/projects/gnuwin32/files/make/3.81/make-3.81.exe/download

  ██████████████████████████████  3.22 MB / 3.22 MB

Successfully verified installer hash

An unexpected error occurred while executing the command:

rename: The system cannot find the file specified.: "C:\Users\USER~1.HP~\AppData\Local\Temp\WinGet\GnuWin32.Make.3.81", "C:\Users\USER~1.HP~\AppData\Local\Temp\WinGet\GnuWin32.Make.3.81.exe"

I make the test with winget 1.0.11692 Windows 10 (1909) and work Ok 👌🏾

The problem is in the version winget 1.0.11694 in Windows 11 Pro Insider (OS Build 22454.1000) when try execute the rename command

xezrunner commented 3 years ago

This issue also occurs with local accounts that have spaces in them. This can be achieved regularly during OOBE by skipping the MSA login and setting up an username with spaces. The same error is thrown as seen above: image

vedantmgoyal9 commented 3 years ago

I think the problem is on Windows 11 build 22458. I'm on build 22454 and everything is running fine. Thanks for opening the issue otherwise I was just going to upgrade my PC.

jedieaston commented 3 years ago

It is borked for me on 22454. If your user folder name is less than 8 characters you probably won't be affected.

ghost commented 3 years ago

Same problem here. Since 22458.1000 winget no longer work with my "special" space character in my Username/Profilepath.. [Update] Some installations work:

PS C:\Users\Simon Lichtlein> winget -v
v1.0.11692
PS C:\Users\Simon Lichtlein> [environment]::OSVersion.Version.Build
22458

PS C:\Users\Simon Lichtlein> winget install eartrumpet
Found EarTrumpet [File-New-Project.EarTrumpet]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Successfully verified installer hash
Starting package install...
  ██████████████████████████████  100%
Successfully installed
PS C:\Users\Simon Lichtlein> winget install notepad++
Found Notepad++ [Notepad++.Notepad++]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.1.4/npp.8.1.4.Installer.x64.exe
  ██████████████████████████████  4.11 MB / 4.11 MB
Successfully verified installer hash
An unexpected error occurred while executing the command:
rename: The system cannot find the file specified.: "C:\Users\SIMONL~1\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4", "C:\Users\SIMONL~1\AppData\Local\Temp\WinGet\Notepad++.Notepad++.8.1.4.exe"

Windows Terminal was also installed without any problems. It seems that only .msixbundle installers can be "renamed".

naveenkrdy commented 3 years ago

Same issue here. "rename" fails on windows 11 build 22458.


Found PowerToys (Preview) [Microsoft.PowerToys] Version 0.45.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/microsoft/PowerToys/releases/download/v0.45.0/PowerToysSetup-0.45.0-x64.exe
  ██████████████████████████████  51.6 MB / 51.6 MB
Successfully verified installer hash
An unexpected error occurred while executing the command:
rename: The system cannot find the file specified.: "C:\Users\NAVEEN~1\AppData\Local\Temp\WinGet\Microsoft.PowerToys.0.45.0", "C:\Users\NAVEEN~1\AppData\Local\Temp\WinGet\Microsoft.PowerToys.0.45.0.exe"
oleksis commented 3 years ago

Get same error with other workaround

➜ echo $env:TMP
C:\Users\USER~1.HP~\AppData\Local\Temp

➜ winget install GnuWin32.Make
Found GnuWin32: Make [GnuWin32.Make]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://sourceforge.net/projects/gnuwin32/files/make/3.81/make-3.81.exe/download
  ██████████████████████████████  3.22 MB / 3.22 MB
Successfully verified installer hash
An unexpected error occurred while executing the command:
rename: The system cannot find the file specified.: "C:\Users\USER~1.HP~\AppData\Local\Temp\WinGet\GnuWin32.Make.3.81", "C:\Users\USER~1.HP~\AppData\Local\Temp\WinGet\GnuWin32.Make.3.81.exe"

➜ $env:TEMP = $env:TMP = (Get-Item -Path $env:TMP).FullName

➜ echo $env:TMP
C:\Users\user.HP450-2\AppData\Local\Temp

➜ echo $env:TEMP
C:\Users\user.HP450-2\AppData\Local\Temp

➜ winget install GnuWin32.Make
Found GnuWin32: Make [GnuWin32.Make]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://sourceforge.net/projects/gnuwin32/files/make/3.81/make-3.81.exe/download
  ██████████████████████████████  3.22 MB / 3.22 MB
Successfully verified installer hash
An unexpected error occurred while executing the command:
rename: The system cannot find the file specified.: "C:\Users\user.HP450-2\AppData\Local\Temp\WinGet\GnuWin32.Make.3.81", "C:\Users\user.HP450-2\AppData\Local\Temp\WinGet\GnuWin32.Make.3.81.exe"
➜ winget --info
Windows Package Manager v1.0.11694
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22458.1000
Package: Microsoft.DesktopAppInstaller v1.15.11694.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

Links
--------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
jedieaston commented 3 years ago

Feedback hub: https://aka.ms/AAdvvje

jedieaston commented 3 years ago

Still not working on 22463:

PS C:\Users\Easton Pillay> winget install spotify
Found Spotify [Spotify.Spotify] Version 1.1.68.632.g2b11de83
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://download.scdn.co/SpotifyFullSetup.exe
  ██████████████████████████████  68.3 MB / 68.3 MB
Successfully verified installer hash
An unexpected error occurred while executing the command:
rename: The system cannot find the file specified.: "C:\Users\EASTON~1\AppData\Local\Temp\WinGet\Spotify.Spotify.1.1.68.632.g2b11de83", "C:\Users\EASTON~1\AppData\Local\Temp\WinGet\Spotify.Spotify.1.1.68.632.g2b11de83.exe"
PS C:\Users\Easton Pillay> winget --info
Windows Package Manager v1.0.12581
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22463.1000
Package: Microsoft.DesktopAppInstaller v1.16.12581.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
PS C:\Users\Easton Pillay>
shivangswain commented 3 years ago

Both the winget install and the winget upgrade commands stopped working for me sometime ago. My username in Windows is shivangswain but for some reason it shows up as SHIVAN~1. PoweShell's built-in Rename-Item command and explorer both can access the file with SHIVAN~1 in the path but somehow the rename in winget messes up.

PS C:\Users\shivangswain> winget upgrade zoom
Found Zoom [Zoom.Zoom] Version 5.8.1324
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licences to, third-party packages.
Downloading https://cdn.zoom.us/prod/5.8.0.1324/x64/ZoomInstallerFull.msi
██████████████████████████████  51.6 MB / 51.6 MB
Successfully verified installer hash
An unexpected error occurred while executing the command:
rename: The system cannot find the file specified.: "C:\Users\SHIVAN~1\AppData\Local\Temp\WinGet\Zoom.Zoom.5.8.1324", "C:\Users\SHIVAN~1\AppData\Local\Temp\WinGet\Zoom.Zoom.5.8.1324.msi"

PS C:\Users\shivangswain> winget --info
Windows Package Manager v1.0.12581
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22458.1000
Package: Microsoft.DesktopAppInstaller v1.16.12581.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
fkelava commented 3 years ago

With the latest information provided by all of you, I renamed the issue to better reflect its root cause and magnitude. I can also confirm that the issue persists in build 22463.

oleksis commented 3 years ago

I download and compile the project for AppInstallerCLI and this commit fix the issue when rename the installer downloaded.

  user2021-09-26 01:41:32  ~/Documents/winget/Microsoft.DesktopAppInstaller_1.16.12581.0_x64__8wekyb3d8bbwe  ﲍ 
➜ .\AppInstallerCLI.exe install --id "GnuWin32.Make"
Found GnuWin32: Make [GnuWin32.Make] Version 3.81
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://sourceforge.net/projects/gnuwin32/files/make/3.81/make-3.81.exe/download
  ██████████████████████████████  3.22 MB / 3.22 MB
Successfully verified installer hash
Starting package install...
Successfully installed
  user2021-09-26 02:02:06  ~/Documents/winget/Microsoft.DesktopAppInstaller_1.16.12581.0_x64__8wekyb3d8bbwe  ﲍ 
➜ .\AppInstallerCLI.exe --info
 v1.0.0
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22463.1000

Logs: %TEMP%\WinGet

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
ItzLevvie commented 3 years ago

Windows Terminal was also installed without any problems. It seems that only .msixbundle installers can be "renamed".

Add-AppxPackage allows you to download from a URL which means the rename isn't handled by WinGet since the files are downloaded to %SystemRoot%\Temp rather than to %TEMP%\WinGet: image image image

jedieaston commented 3 years ago

This has been resolved in the latest release of winget (v1.1.12653):

S C:\Users\Easton Pillay\projects\winget-pkgs\manifests\a\AgileBits\1Password> winget install spotify --source winget
Found Spotify [Spotify.Spotify] Version 1.1.68.632.g2b11de83
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://download.scdn.co/SpotifyFullSetup.exe
  ██████████████████████████████  68.3 MB / 68.3 MB
Successfully verified installer hash
Starting package install...
Successfully installed
PS C:\Users\Easton Pillay\projects\winget-pkgs\manifests\a\AgileBits\1Password> winget --info
Windows Package Manager v1.1.12653
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22463.1000
Package: Microsoft.DesktopAppInstaller v1.16.12653.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Either spam the update button in the Microsoft Store until you get an update or download it here.

fkelava commented 3 years ago

Fix confirmed in v1.1.12653. winget upgrade and winget install now function as expected for .exe and .msi installers. See:

PS C:\Users\fran.kelava> winget upgrade Notepad++
Found Notepad++ [Notepad++.Notepad++] Version 8.1.5
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.1.5/npp.8.1.5.Installer.x64.exe
  ██████████████████████████████  4.13 MB / 4.13 MB
Successfully verified installer hash
Starting package install...
Successfully installed

PS C:\Users\fran.kelava> winget upgrade Cisco.WebexTeams
Found Webex [Cisco.WebexTeams] Version 41.9.0.20091
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://binaries.webex.com/WebexTeamsDesktop-Windows-Gold/Webex.msi
  ██████████████████████████████   242 MB /  242 MB
Successfully verified installer hash
Starting package install...
Successfully installed
PS C:\Users\fran.kelava> winget install qBittorrent.qBittorrent
Found qBittorrent [qBittorrent.qBittorrent] Version 4.3.5
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://sourceforge.net/projects/qbittorrent/files/qbittorrent-win32/qbittorrent-4.3.5/qbittorrent_4.3.5_x64_setup.exe/download
  ██████████████████████████████  25.9 MB / 25.9 MB
Successfully verified installer hash
Starting package install...
Successfully installed

PS C:\Users\fran.kelava> winget install meld.meld
Found Meld [Meld.Meld] Version 3.20.4
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://download.gnome.org/binaries/win32/meld/3.20/Meld-3.20.4-mingw.msi
  ██████████████████████████████  42.6 MB / 42.6 MB
Successfully verified installer hash
Starting package install...
Successfully installed

with versions:

Windows Package Manager v1.1.12653
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22463.1000
Package: Microsoft.DesktopAppInstaller v1.16.12653.0