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

x64 version of winget does install x64 packages on arm system, instead of the arm variant #2731

Open marticliment opened 1 year ago

marticliment commented 1 year ago

Brief description of your issue

If a x64 version is ran on a arm64 machine through emulation, winget will install the x64 version of a package instead of the arm64.

While the user usually has the proper version installed, sometimes, especially with bundled winget executables (such as the one on WingetUI) often cause issues.

This issue applies to updates as well, where Winget will install the x64 update over the previous arm package

Steps to reproduce

Run a x64 version of Winget on an arm system through emulation.

Anothger way is to use the bundled winget executable in WingetUI)

Expected behavior

Winget detected the proper system architecture and installed the corresponding packages, regardless of the architecture of the process itself.

Actual behavior

Winget x64 emulated on arm installs x64 packages on arm machines

Environment

winget --info
Windows-Paket-Manager v1.3.2691
Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.
denelon commented 1 year ago

Can you share the output of winget --info when emulated to see if the architecture is correctly detected?

mirogl commented 1 year ago

Hi - the output of the bundled version is:

winget.exe --info
Windows Package Manager v1.3.0
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.900
System Architecture: X64

Logs: %TEMP%\WinGet\defaultState

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

The output from my local installed version is

winget --info
Windows-Paket-Manager v1.3.2691
Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.

Windows: Windows.Desktop v10.0.22621.900
Systemarchitektur: Arm64
Paket: Microsoft.DesktopAppInstaller v1.18.2691.0

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

Links
-----------------------------------------------------------------------------------------
Datenschutzerklärung              https://aka.ms/winget-privacy
Lizenzvereinbarung                https://aka.ms/winget-license
Hinweise von Drittanbietern       https://aka.ms/winget-3rdPartyNotice
Startseite                        https://aka.ms/winget
Windows Store Nutzungsbedingungen https://www.microsoft.com/en-us/storedocs/terms-of-sale

Thanks Miro

denelon commented 1 year ago

I see. The "System Architecture" from the bundled version isn't one of our "official releases". Hopefully there is something we can do to detect the architecture differently, but I'm not sure if that's possible.

Masamune3210 commented 1 year ago

maybe GetNativeSystemInfo?

https://devblogs.microsoft.com/oldnewthing/20220209-00/?p=106239

denelon commented 1 year ago

As a workaround, you can specify architecture via command line, or you can modify your settings to "prefer" the ARM version of packages.

denelon commented 1 year ago

@marticliment just an FYI.

Here is another Issue related to https://github.com/marticliment/WingetUI.

marticliment commented 1 year ago

Hello,

I have found a possible workaround for this issue. It consists on reading the vaule for the environment variable %PROCESSOR_ARCHITECTURE%. This is the workaround I used on WingetUI to detect arm64 machines from an executable compiled for x86_64 systems, and it appears to work correctly.