Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Aster-the-Med-Stu opened this issue Oct 13, 2020 · 11 comments

Comments

@Aster-the-Med-Stu
Copy link

Aster-the-Med-Stu commented Oct 13, 2020

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.

@rashil2000 rashil2000 changed the title [Feature Request] Offer a flag to skip updates that failed to download [Feature Request] Offer a flag to skip installs/updates that failed to download Jan 8, 2022
@Edge-coordinates
Copy link

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
Copy link
Member

scoop help hold

@Edge-coordinates
Copy link

scoop help hold

Okk,thank you!

@Lutra-Fs
Copy link
Contributor

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
Copy link
Member

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
Copy link

logonoff commented Nov 16, 2023

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
Copy link

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
Copy link

go-xoxo commented Nov 25, 2023

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
Copy link

ViCrack commented Jan 11, 2024

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
Copy link

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
Copy link

ViCrack commented Jan 26, 2024

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.

#4135 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants