ScoopInstaller / Scoop

A command-line installer for Windows.
https://scoop.sh
Other
21.05k stars 1.4k forks source link

[Bug] scoop hold barfs on app in installation failed state #5273

Closed hgkamath closed 5 months ago

hgkamath commented 1 year ago

Bug Report

summary:
Want to skip upgrade of app which has installer failure. Hence, trying to scoop hold it. Scoop, while attempting to scoop hold the app in invalid state, does not handle situation and throws an error.
scoop hold says that app is held, but it doesn't seem like it.
Upon scoop update -g "*". scoop still attempts to update app.

Current Behavior

scoop throws an unhandled error.
scoop claims to hold app, but really doesn't

Expected Behavior

scoop should handle the error gracefully,
scoop should yet still manage to hold the app, and skip future upgrades

Additional context/output

presently, qemu installer has a problem. perhaps transient https://gitlab.com/qemu-project/qemu/-/issues/1349 Windows Installer Error https://github.com/ScoopInstaller/Main/issues/4164 QEMU 7.2.0-rc2 unable to extract qemu-uninstall.exe.nsis

The scoop update partially goes through, creates the new app directory and extracts the files, but installer fails.
so directories for qemu rc1, rc2 and rc3 exist

I attempted to do a scoop hold to prevent further updates until qemu-project/scoop devs sort it out.

PS E:\> scoop list
Installed apps:

Name            Version                  Source Updated             Info
----            -------                  ------ -------             ----
:
qemu            7.2.0-rc1                main   2022-11-18 23:12:44 Global install, Install failed
:

PS E:\> scoop hold -g qemu
Get-Member : You must specify an object for the Get-Member cmdlet.
At C:\vol\scoop_01\SCOOP\apps\scoop\current\libexec\scoop-hold.ps1:58 char:13
+     $json | Get-Member -MemberType Properties | ForEach-Object { $ins ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-Member], InvalidOperationException
    + FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand

Exception calling "WriteAllLines" with "2" argument(s): "Could not find a part of the path
'C:\vol\scoop_01\SCOOPG\apps\qemu\current\install.json'."
At C:\vol\scoop_01\SCOOP\apps\scoop\current\lib\manifest.ps1:96 char:5
+     [System.IO.File]::WriteAllLines("$dir\install.json", $file_conten ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DirectoryNotFoundException

qemu is now held and can not be updated anymore.

PS E:\> scoop list
:
qemu            7.2.0-rc1                main   2022-11-18 23:12:44 Global install, Install failed
:

PS E:\> scoop status qemu
Scoop is up to date.

Name Installed Version Latest Version Missing Dependencies Info
---- ----------------- -------------- -------------------- ----
qemu 7.2.0-rc1         7.2.0-rc3                           Install failed

PS E:\> scoop update -g "*"
qemu: 7.2.0-rc1 -> 7.2.0-rc3 (global)
Updating one outdated app:
Updating 'qemu' (7.2.0-rc1 -> 7.2.0-rc3)
Downloading new version
Loading qemu-w64-setup-20221130.exe from cache
Checking hash of qemu-w64-setup-20221130.exe ... ok.
Uninstalling 'qemu' (7.2.0-rc1)
Installing 'qemu' (7.2.0-rc3) [64bit] from main bucket
Loading qemu-w64-setup-20221130.exe from cache
Extracting dl.7z ... ERROR Exit code was 2!
Failed to extract files from C:\vol\scoop_01\SCOOPG\apps\qemu\7.2.0-rc3\dl.7z.
  C:\vol\scoop_01\SCOOPG\apps\qemu\7.2.0-rc3\7zip.log

Please try again or create a new issue by using the following link and paste your console output:
https://github.com/ScoopInstaller/Main/issues/new?title=qemu%407.2.0-rc3%3a+decompress+error

Example of trying to hold an app which is not installed

PS E:\> scoop hold -g jq
ERROR 'jq' is not installed globally.

Example of holding a regular installed app

PS E:\vstorage\nbd\wnbd_client> scoop hold -g vlc
vlc is now held and can not be updated anymore.
PS E:\> scoop list
: 
vlc             3.0.18                   extras 2022-12-04 09:55:34 Global install, Held package
: 
PS E:\vstorage\nbd\wnbd_client> scoop unhold -g vlc
vlc is no longer held and can be updated again.

Possible Solution

One possible solution:
revert to older version of app and hold that

Another possible solution :
press ctrl-C when scoop upgrade -g * starts to upgrade app, and update any other subsequent app manually.

System details

Windows version: [e.g. 7, 8, 10, 11] Windows-10 22H2 19045.2311

OS architecture: [e.g. 32bit, 64bit, arm64] 64-bit

PowerShell version: [output of "$($PSVersionTable.PSVersion)"] 5.1.19041.1682

Additional software: [(optional) e.g. ConEmu, Git]

Scoop Configuration

//# Your configuration here
rashil2000 commented 1 year ago

Hmm I guess we should check for installation status before trying to hold the application. Should be an easy fix. Can you make a PR?