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.25k stars 1.45k forks source link

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

Closed farag2 closed 1 year ago

farag2 commented 1 year ago

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 commented 1 year ago

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

Trenly commented 1 year ago

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

farag2 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@Trenly, @denelon

farag2 commented 1 year ago

Did additional tests. So, as a summary

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>
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>
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>
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

denelon commented 1 year ago

@farag2 Thanks for the detailed analysis!

Maicarons commented 1 year ago

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

farag2 commented 1 year ago

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