ScoopInstaller / Scoop

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

[Feature Request] Offer a flag to skip installs/updates that failed to download #4135

Open Aster-the-Med-Stu opened 4 years ago

Aster-the-Med-Stu commented 4 years ago

When installing more apps using scoop, upgrading all applications using scoop update * would frequently fail, mainly because a maintainer didn't keep up with the newest version.

Updating 25 outdated apps:
Updating 'magicavoxel' (0.99.4 -> 0.99.6)
Downloading new version
The remote server returned an error: (404) Not Found.
At C:\Users\Aster\scoop\apps\scoop\current\lib\install.ps1:130 char:9
+         throw $e
+         ~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], WebException
    + FullyQualifiedErrorId : The remote server returned an error: (404) Not Found.

And one failed update would break others to continue! I know I could hold an app and retry again, but that would be too painful.

Edge-coordinates commented 2 years ago

I think even if this function cannot be implemented, the update command can add the function of excluding certain software during the update, which should be more convenient.

rashil2000 commented 2 years ago

scoop help hold

Edge-coordinates commented 2 years ago

scoop help hold

Okk,thank you!

Lutra-Fs commented 1 year ago

Any updates on this one? If no one is working on this issue, may I work on this one? I would like to introduce a new flag, but I didn't know which name is okay for this feature. What I planned is to introduce a parameter for install_app called exit_when_error, default to true, and if false use error function to output error instead of abort for the other functions may abort the process. May I know if that is a okay solution?

rashil2000 commented 1 year ago

Any updates on this one? If no one is working on this issue, may I work on this one? I would like to introduce a new flag, but I didn't know which name is okay for this feature. What I planned is to introduce a parameter for install_app called exit_when_error, default to true, and if false use error function to output error instead of abort for the other functions may abort the process. May I know if that is a okay solution?

Yes @Lutra-Fs, please go ahead!

logonoff commented 12 months ago

I just wrote a quick script which does this for anyone who's interested:

scoop update;
foreach ($app in (scoop status)) {
    if ($APP.Info -eq "Held package") {
        continue;
    }

    try {
        scoop update $app.Name;
    }
    catch {
        Write-Output "$($app.Name) failed to update!"
        scoop reset $app.Name;
    }

    if ($LASTEXITCODE -ne 0 -or $? -eq $FALSE) {
        Write-Output "$($app.Name) failed to update!"
        scoop reset $app.Name;
    }
}

If there are any improvements that can be made to this, please let me know!

updated 2024-02-29 to fix this script not working with gifsicle broke

AntonOks commented 11 months ago

Thanks for the idea and code :) As I allways have some "frozen" packages, I'd sipping those "held" ones with an extra IF check. Therefore my code would look like below:

foreach ($APP in (scoop status)) {
    if ($APP.Info -eq "Held package") {
        Write-Host -ForegroundColor DARKBLUE -BackgroundColor WHITE "`"$($APP.Name)`"" -NoNewline
        Write-Host ": skipped held package."
        continue
    }
    scoop update $APP.Name;

    if ($LASTEXITCODE -ne 0) {
        Write-Host -ForegroundColor RED -BackgroundColor WHITE "`"$($APP.Name)`""
        Write-Host ": failed to update!"
        scoop reset $APP.Name;
    }
}
go-xoxo commented 11 months ago

thank you guys for the powershell scripts.. that helps.. i wanted to ask nevertheless if this feature is going to be implemented or what the status is.

ViCrack commented 10 months ago

I wrote a temporary and simple python3 script for batch updating.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Date    : 2024/1/11
@Author  : vicrack

The scoop update command is too slow.
This script uses multiple processes to update Scoop programs concurrently, increasing speed.
Even if one program fails to update, it won't affect the others.
"""
import re
import subprocess
import multiprocessing

def get_updates():
    status_output = subprocess.check_output("scoop.cmd status")
    lines = status_output.decode().splitlines()

    # Find the programs that need updating
    updates = set()
    in_updates = False
    for line in lines:
        line = line.strip()
        if line:
            data = line.split()
            if data[0].endswith("----"):
                in_updates = True
            elif in_updates:
                program = data[0]
                if not line.endswith(('Held package', 'Manifest removed')):
                    updates.add(program)

    return updates

def update_program(program):
    # Skip hash validation!
    subprocess.run(f"scoop.cmd update {program} -s")

def main():
    # update scoop, buckets
    subprocess.run('scoop.cmd update')
    updates = get_updates()
    if not updates:
        print("No updates available.")
        exit(0)

    print(updates)
    # Update multiple programs concurrently using multiple processes
    with multiprocessing.Pool(processes=5) as pool:
        pool.map(update_program, updates)

    # subprocess.run('scoop.cmd cache rm *')
    # subprocess.run('scoop.cmd cleanup *')

if __name__ == "__main__":
    main()
graphixillusion commented 9 months ago

I wrote a temporary and simple python3 script for batch updating.

This script works under Windows 11 but doesn't work under Windows 10. Apparently scoop status appends to the output the ascii for color codes and it always output No updates available. even when there are updates available. Do you know how to fix this?

ViCrack commented 9 months ago

I wrote a temporary and simple python3 script for batch updating.

This script works under Windows 11 but doesn't work under Windows 10. Apparently scoop status appends to the output the ascii for color codes and it always output No updates available. even when there are updates available. Do you know how to fix this?

possibly a bug, I will fix this.

https://github.com/ScoopInstaller/Scoop/issues/4135#issuecomment-1886146727