winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

winget cannot extract portable archive if it contains folder with --location argument that differes from %SystemDrive%

Open farag2 opened this issue 1 year ago • 7 comments

Brief description of your issue

I want to determine another folder on D drive to extract a portable software, but no matter how I use --location, it fails.

Screenshot 2023-02-07 010440

Steps to reproduce

winget install --id=TeamSophia.SophiApp --exact --accept-source-agreements --location "D:\test"

Expected behavior

The ZIP archive should be extracted without errors.

Actual behavior

I receive An unexpected error occurred while executing the command: copy_file: �������� � �������.: "C:\Users\SANCTU~1\AppData\Local\Temp\WinGet\TeamSophia.SophiApp.1.0.94\extracted\SophiApp", "D:\test\SophiApp"

# This works
winget install --id=TeamSophia.SophiApp --exact --accept-source-agreements --location "C:\test"

Also, tested with admin rights and as a user. The behavior is the same.

Environment

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

Windows: Windows.Desktop v10.0.22621.1194
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.19.10173.0
Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
User Settings: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json

farag2 avatar Feb 06 '23 22:02 farag2

From my perspective of view, something is going wrong here: https://github.com/microsoft/winget-cli/blob/fcce38f532439fc4a7294c246c1eb19d146acea4/src/AppInstallerCommonCore/Filesystem.cpp#L133

farag2 avatar Feb 06 '23 22:02 farag2

I think this is package specific, since I tried with USSF winget install WindowsPostInstallWizard.UniversalSilentSwitchFinder --Location D:\Test\ and it worked fine

Trenly avatar Feb 07 '23 05:02 Trenly

@Trenly, WindowsPostInstallWizard has only one exe file in archive. Can it be the reason that its' archive can be expanded? I do not see any differences between SophiApp fundamental structure (probably, at least it has a folder in archive) and the WindowsPostInstallWizard archive.

So, any thoughts how to fix the issue?

farag2 avatar Feb 07 '23 10:02 farag2

I did some local tests. I noticed that if an archive contains any folder, it cannot be extracted. I removed the Bin folder from the archive and moved all files to the root. and it works perfectly.

изображение

Can it be considered as an issue as winget cannot extract archives with folders inside?

farag2 avatar Feb 08 '23 11:02 farag2

@Trenly, @denelon

farag2 avatar Feb 08 '23 18:02 farag2

Did additional tests. So, as a summary

  • winget failed to install if archive contains root folder with files and folders inside with --location "D:\test". But successfully installs without --location "D:\test".
PS C:\Users\Sanctuary\Desktop> winget install --manifest C:\Users\Sanctuary\Desktop\t\test1\test1\1 --location "D:\test"
Found SophiApp [test1.test1] Version 1
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
Extracting archive...
Successfully extracted archive
Starting package install...
An unexpected error occurred while executing the command:
copy_file: �������� � �������.: "C:\Users\SANCTU~1\AppData\Local\Temp\WinGet\test1.test1.1\extracted\SophiApp", "D:\test\SophiApp"
Portable install failed; Cleaning up...
PS C:\Users\Sanctuary\Desktop>
  • winget failed to install if archive contains root folder with files only inside with --location "D:\test". Also failed to install without --location "D:\test".
PS C:\Users\Sanctuary\Desktop> winget install --manifest C:\Users\Sanctuary\Desktop\t\test2\test2\2 --location "D:\test"
Found SophiApp [test2.test2] Version 2
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
Extracting archive...
Successfully extracted archive
Starting package install...
An unexpected error occurred while executing the command:
copy_file: �������� � �������.: "C:\Users\SANCTU~1\AppData\Local\Temp\WinGet\test2.test2.2\extracted\SophiApp", "D:\test\SophiApp"
Portable install failed; Cleaning up...
PS C:\Users\Sanctuary\Desktop>
  • winget failed to install if archive contains NO root folder with files and folders inside with --location "D:\test". But successfully installs without --location "D:\test".
PS C:\Users\Sanctuary\Desktop> winget install --manifest C:\Users\Sanctuary\Desktop\t\test3\test3\3 --location "D:\test"
Found sophiapp [test3.test3] Version 3
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
Extracting archive...
Successfully extracted archive
Starting package install...
An unexpected error occurred while executing the command:
copy_file: �������� � �������.: "C:\Users\SANCTU~1\AppData\Local\Temp\WinGet\test3.test3.3\extracted\Bin", "D:\test\Bin"
Portable install failed; Cleaning up...
PS C:\Users\Sanctuary\Desktop>
  • winget successfully installs if archive contains NO root folder with files only inside with --location "D:\test".
PS C:\Users\Sanctuary\Desktop> winget install --manifest C:\Users\Sanctuary\Desktop\t\test4\test4\4 --location "D:\test"
Found sophiapp [test4.test4] Version 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://github.com/Sophia-Community/SophiApp/releases/download/1.0.87/4.zip
  ██████████████████████████████   577 KB /  577 KB
Successfully verified installer hash
Extracting archive...
Successfully extracted archive
Starting package install...
Command line alias added: "sophiapp"
Successfully installed
PS C:\Users\Sanctuary\Desktop>

@Trenly, @denelon, @ryfu-msft

farag2 avatar Feb 10 '23 16:02 farag2

@farag2 Thanks for the detailed analysis!

denelon avatar Feb 10 '23 16:02 denelon

I found the issue still.

My version is the latest

C:\Windows\System32>winget -v
v1.4.11071

my setting file:

"portablePackageUserRoot": "D:/Users/****/Packages",
"portablePackageMachineRoot": "D:/Program Files/Packages/Portable"

and now I cannot install anything with print which is the same as farag2

Maicarons avatar Jun 13 '23 01:06 Maicarons

@Maicarons It works in https://github.com/microsoft/winget-cli/releases/tag/v1.5.1081-preview Waiting for 1.5 release :cat:

farag2 avatar Jun 13 '23 09:06 farag2