microsoft / winget-pkgs

The Microsoft community Windows Package Manager manifest repository
MIT License
8.51k stars 4.4k forks source link

[Package Issue]: Microsoft.VisualStudio.2022.Enterprise fails with "catastrophic failure" #118182

Closed exoosh closed 4 months ago

exoosh commented 1 year ago

Please confirm these before moving forward

Category of the issue

Installation issue.

Brief description of your issue

Upgrading Microsoft.VisualStudio.2022.Enterprise fails with:

>winget upgrade --id Microsoft.VisualStudio.2022.Enterprise
Found Visual Studio Enterprise 2022 [Microsoft.VisualStudio.2022.Enterprise] Version 17.7.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
Starting package install...
Installer failed with exit code: 8006
An unexpected error occurred while executing the command:
0x8000ffff : Catastrophic failure

Observations

I then went ahead and used the interactive method of upgrading Visual Studio and it turned out that PowerShell (PS Core, i.e. pwsh in my case) was running and the Visual Studio Installer was complaining about that.

And indeed PowerShell was running in Windows Terminal with the following command line:

"%ProgramFiles%\PowerShell\7\pwsh.exe" -NoLogo -NoExit -Command "&{Import-Module """%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell 3ea3f535 -SkipAutomaticLocation -DevCmdArguments """-arch=x64 -host_arch=x64"""}"

I know Windows Installer has a way to schedule files to be moved/deleted at reboot via the session manager (effectively through MoveFileEx with flag MOVEFILE_DELAY_UNTIL_REBOOT or an equivalent method). Perhaps that's what missing? Anything else would require the upgrade to always be interactive, which seems undesirable.

Steps to reproduce

Not sure, for me it was merely trying the upgrade with while PS Core was running with the Developer Prompt open in a tab:

winget upgrade --id Microsoft.VisualStudio.2022.Enterprise

Actual behavior

Getting a failure:

Installer failed with exit code: 8006
An unexpected error occurred while executing the command:
0x8000ffff : Catastrophic failure

Expected behavior

I expected the upgrade to be performed.

Environment

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

Windows: Windows.Desktop v10.0.19045.3324
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.20.1881.0

Winget Directories
-------------------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages

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                        Enabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled


### Screenshots and Logs

![image](https://github.com/microsoft/winget-pkgs/assets/81239903/e8a2f994-1b58-4b9c-9b35-e260fcbf075e)
stephengillie commented 1 year ago

Hi @exoosh,

If I'm understanding correctly, the error was caused by another installer being open. This might be expected, as only one install can proceed at a time.

How would you prefer WinGet to respond when it's installing something and there's already an installer open? Should it error and abort, kill the other installer and proceed, or retry when the other install is complete?

exoosh commented 1 year ago

Hi @stephengillie,

not another installer but PowerShell running with the VS Developer Prompt open (i.e. %ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll in use). And yes, in case of the interactive installation I did get a prompt showing pwsh to be the culprit, and subsequently closed the tab after which the installation was able to proceed.

I am not really sure what installer technology VS uses under the hood, but it looked akin to Windows Installer. Windows Installer has a mode that allows it to proceed with the installation despite some component being in use by using MoveFileEx as pointed out above. So essentially it would schedule the new component to be moved into the place of the old one upon next reboot.

What's also interesting is that I noticed this the first time around now in the upgrade to 17.7.2 although I have had the PowerShell Dev Prompt as a default in Windows Terminal for a long time (and it was thus in use all the same).

PS: I am not even sure that winget is necessarily to blame here, could as well be a change in the VS installer. But since I have used winget for months to keep VS up-to-date, and this was the first time it failed, I thought I'd type up a defect report.

exoosh commented 4 months ago

I have since updated VS2022 several times using winget and never saw this issue again. So I guess this could be closed?!