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

`winget upgrade -e --id Git.Git` always fails, after removing git #3479

Open BrianL-STCU opened 1 year ago

BrianL-STCU commented 1 year ago

Brief description of your issue

When upgrading git, the installer always removes git, then fails to install the new version, leaving the machine without git.

Running winget upgrade --all will also result in uninstalling git.

Steps to reproduce

winget upgrade -e --id Git.Git

or

winget upgrade --all

Expected behavior

Git should be updated to the new version, or if there is a problem, the previous version should be restored.

Actual behavior

Git is removed from the system.

Environment

Windows Package Manager (Preview) v1.5.441-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19045.3208
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.20.441.0

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

User Settings: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json

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

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
BrianL-STCU commented 1 year ago

From _%LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller8wekyb3d8bbwe\LocalState\DiagOutputDir\WinGet-Git.Git.2.41.0.3-2023-07-27-15-53-00.988.log:

2023-07-27 15:53:15.293   Starting the installation process.
2023-07-27 15:53:15.308   Creating directory: C:\Program Files\Git\dev
2023-07-27 15:53:15.308   Fatal exception during installation process (Exception):
                          Setup was unable to create the directory "C:\Program Files\Git\dev".

                          Error 5: Access is denied.
2023-07-27 15:53:15.308   Exception message:
2023-07-27 15:53:15.308   Defaulting to OK for suppressed message box (OK):
                          Setup was unable to create the directory "C:\Program Files\Git\dev".

                          Error 5: Access is denied.
2023-07-27 15:53:15.308   Defaulting to OK for suppressed message box (OK):
                          Setup was not completed.

                          Please correct the problem and run Setup again.
2023-07-27 15:53:15.308   Rolling back changes.
2023-07-27 15:53:15.312   Starting the uninstallation process.
2023-07-27 15:53:15.879   Uninstallation process succeeded.
2023-07-27 15:53:17.386   Deinitializing Setup.
2023-07-27 15:53:17.409   Log closed.
BrianL-STCU commented 1 year ago

I'm running in a corporate environment under an unprivileged account, entering privileged account credentials when prompted by the installer. I'm not able to run winget itself under the privileged account, because that results in this error:

Failed when searching source: winget
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing

Even getting that far under that account was a huge battle because winget doesn't have a simple installer. After trying a bunch of suggestions in #1861, I've gotten it only this far.

Under that account, winget source list returns:

Name    Argument
-----------------------------------------------------
msstore https://storeedgefd.dsx.mp.microsoft.com/v9.0
winget  https://cdn.winget.microsoft.com/cache

Under that account, winget --info returns:

Windows Package Manager (Preview) v1.5.441-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19045.3208
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.20.441.0

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

User Settings: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json

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

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Enabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
denelon commented 1 year ago

When Git is installed, unfortunately, it checks which "user" is performing the install. If the user is a member of local administrators it attempts to install machine wide. That has caused problems with scope. I've also seen a report on 32-bit Windows.

It looks like you're running an earlier preview. And I've seen some ACL related issues as well:

I'm not sure how to exactly reproduce what you're seeing yet.

The latest manifest for Git.Git isn't calling uninstallPrevious so it's likely the Git installer is doing the removal.

Out of curiosity, after this happens can you install the latest version? Does it get installed machine wide or for a single user? I suspect the installer, but I don't want to mark this issue as "Area-External" until we've ruled out the potential for the ACL problem.

BrianL-STCU commented 1 year ago

After the upgrade fails, running winget install -e --id Git.Git -s winget (as the unelevated user) continues to fail for the same reason.

2023-07-31 07:45:04.812   Line 132: First directory in hierarchy that already exists is "C:\Program Files\Git".
2023-07-31 07:45:04.847   Starting the installation process.
2023-07-31 07:45:04.849   Creating directory: C:\Program Files\Git\dev
2023-07-31 07:45:04.850   Fatal exception during installation process (Exception):
                          Setup was unable to create the directory "C:\Program Files\Git\dev".

                          Error 5: Access is denied.
2023-07-31 07:45:04.850   Exception message:
2023-07-31 07:45:04.850   Defaulting to OK for suppressed message box (OK):
                          Setup was unable to create the directory "C:\Program Files\Git\dev".

                          Error 5: Access is denied.
2023-07-31 07:45:04.850   Defaulting to OK for suppressed message box (OK):
                          Setup was not completed.

                          Please correct the problem and run Setup again.
2023-07-31 07:45:04.850   Rolling back changes.
2023-07-31 07:45:04.855   Starting the uninstallation process.
2023-07-31 07:45:04.886   Uninstallation process succeeded.
2023-07-31 07:45:06.401   Deinitializing Setup.
2023-07-31 07:45:06.416   Log closed.

Checking the permissions of C:\Program Files\Git shows that my unelevated account has only read access, while the elevated account has read/write.

If I manually create the dev directory with the elevated account, it fails again:

2023-07-31 07:55:02.576   Starting the installation process.
2023-07-31 07:55:02.579   Creating directory: C:\Program Files\Git\dev\mqueue
2023-07-31 07:55:02.579   Fatal exception during installation process (Exception):
                          Setup was unable to create the directory "C:\Program Files\Git\dev\mqueue".

                          Error 5: Access is denied.
2023-07-31 07:55:02.579   Exception message:
2023-07-31 07:55:02.579   Defaulting to OK for suppressed message box (OK):
                          Setup was unable to create the directory "C:\Program Files\Git\dev\mqueue".

                          Error 5: Access is denied.
2023-07-31 07:55:02.579   Defaulting to OK for suppressed message box (OK):
                          Setup was not completed.

                          Please correct the problem and run Setup again.
2023-07-31 07:55:02.579   Rolling back changes.
2023-07-31 07:55:02.584   Starting the uninstallation process.
2023-07-31 07:55:02.622   Uninstallation process succeeded.
2023-07-31 07:55:04.137   Deinitializing Setup.
2023-07-31 07:55:04.152   Log closed.

If I manually create that one, it fails again:

2023-07-31 07:58:27.965   Starting the installation process.
2023-07-31 07:58:27.967   Creating directory: C:\Program Files\Git\dev\shm
2023-07-31 07:58:27.968   Fatal exception during installation process (Exception):
                          Setup was unable to create the directory "C:\Program Files\Git\dev\shm".

                          Error 5: Access is denied.
2023-07-31 07:58:27.968   Exception message:
2023-07-31 07:58:27.968   Defaulting to OK for suppressed message box (OK):
                          Setup was unable to create the directory "C:\Program Files\Git\dev\shm".

                          Error 5: Access is denied.
2023-07-31 07:58:27.968   Defaulting to OK for suppressed message box (OK):
                          Setup was not completed.

                          Please correct the problem and run Setup again.
2023-07-31 07:58:27.968   Rolling back changes.
2023-07-31 07:58:27.972   Starting the uninstallation process.
2023-07-31 07:58:28.011   Uninstallation process succeeded.
2023-07-31 07:58:29.516   Deinitializing Setup.
2023-07-31 07:58:29.532   Log closed.

Same for C:\Program Files\Git\tmp, but then it fails trying to write the uninstall log:

2023-07-31 08:00:41.415   Starting the installation process.
2023-07-31 08:00:41.418   Creating directory: C:\Program Files\Git\tmp
2023-07-31 08:00:41.418   Fatal exception during installation process (Exception):
                          Setup was unable to create the directory "C:\Program Files\Git\tmp".

                          Error 5: Access is denied.
2023-07-31 08:00:41.418   Exception message:
2023-07-31 08:00:41.418   Defaulting to OK for suppressed message box (OK):
                          Setup was unable to create the directory "C:\Program Files\Git\tmp".

                          Error 5: Access is denied.
2023-07-31 08:00:41.418   Defaulting to OK for suppressed message box (OK):
                          Setup was not completed.

                          Please correct the problem and run Setup again.
2023-07-31 08:00:41.418   Rolling back changes.
2023-07-31 08:00:41.423   Starting the uninstallation process.
2023-07-31 08:00:41.462   Uninstallation process succeeded.
2023-07-31 08:00:42.971   Deinitializing Setup.
2023-07-31 08:00:42.987   Log closed.

Running the install as the elevated account doesn't work at all:

PS C:\> winget install -e --id Git.Git -s winget
Failed when opening source(s); try the 'source reset' command if the problem persists.
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing
PS C:\> winget source reset
The following sources will be reset if the --force option is given:
Name    Argument
-----------------------------------------------------
msstore https://storeedgefd.dsx.mp.microsoft.com/v9.0
winget  https://cdn.winget.microsoft.com/cache
PS C:\> winget source reset --force
Resetting all sources...Done
PS C:\> winget install -e --id Git.Git -s winget
Failed when opening source(s); try the 'source reset' command if the problem persists.
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing