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

[BUG] "Run cleanup and clear cache" doesn't clean Scoop's cache #2151

Closed
4 tasks done
redactedscribe opened this issue Apr 19, 2024 · 11 comments
Closed
4 tasks done

[BUG] "Run cleanup and clear cache" doesn't clean Scoop's cache #2151

redactedscribe opened this issue Apr 19, 2024 · 11 comments
Assignees
Labels
bug Something isn't working ready-to-go scoop
Milestone

Comments

@redactedscribe
Copy link

Please confirm these before moving forward

  • I have searched for my issue and have not found a work-in-progress/duplicate/resolved issue.
  • I have tested that this issue has not been fixed in the latest (beta or stable) release.
  • I have checked the FAQ section for solutions
  • This issue is about a bug (if it is not, please use the correct template)

Describe your issue

The Run button for "Run cleanup and clear cache" under Scoop in the Settings only removes old versions of installed Scoop apps. It does not clear/clean/remove the cached downloads, which it should.

Steps to reproduce the issue

No response

WingetUI Log

-

Package Managers Logs

-

Relevant information

No response

Screenshots and videos

No response

@redactedscribe redactedscribe added the bug Something isn't working label Apr 19, 2024
@marticliment
Copy link
Owner

Please attach the contents of the file on C:\Program Files\WingetUI\Assets\Utilities\scoop_cleanup.cmd

@redactedscribe
Copy link
Author

@echo off
echo This script will clean the Scoop cache and run the cleanup command.
echo|set/p="Press <ENTER> to continue or CLOSE this window to abort this process"&runas/u: "">NUL
cls
echo Cleaning Scoop cache...
scoop cleanup --all --global
scoop cache rm --all --global
scoop cleanup --all
scoop cache rm --all
echo Done!
pause

@marticliment
Copy link
Owner

And running this script manually doesn't work either?

@redactedscribe
Copy link
Author

redactedscribe commented Apr 19, 2024

  1. Update 2 Scoop packages.
  2. Scoop\Cache dir now has a ZIP and a 7Z.
  3. Press the Run button in WingetUI settings, then Enter to confirm prompt.
  4. Cache dir still has the archives.
Cleaning Scoop cache...
Removing rpcs3: 0.0.31-16354
Removing zig-dev: 0.12.0-dev.3678
Everything is shiny now!

C:\Windows\System32>

Running the CMD file directly in an Administrator command prompt also does the same: Cache dir is not emptied. Only old app versions removed. Strange.

If I run scoop cache rm --all, the Cache dir is emptied.

The Run button used to work correctly and empty the Cache dir I think. Not any more apparently.

@redactedscribe
Copy link
Author

I have no evidence for it, but it might be a conflict with Clink (it has caused me an unrelated mysterious command prompt issue in the past).

I just uninstalled Clink and tried again. Cache dir still doesn't get emptied.

@marticliment
Copy link
Owner

What happens if you run the script on a non-admin command prompt?

@redactedscribe
Copy link
Author

Cleaning Scoop cache...
ERROR: you need admin rights to cleanup global apps

@redactedscribe
Copy link
Author

redactedscribe commented Apr 20, 2024

As you can see from my third comment from the top, the output of the cache clearing command is immediately followed by the old version removal command's output:

Cleaning Scoop cache...
Removing rpcs3: 0.0.31-16354
<snip>

I always presumed this to be some issue with the CMD script, because when we run scoop cache rm --all by itself, we see what is actually being cleared and its size:

> scoop cache rm --all
Removing https_github.com_vladimir-kotikov_clink-completions_archive_v0.5.2.zip...
Removing https_github.com_chrisant996_clink_releases_download_v1.6.12_clink.1.6.12.5cd618.zip...
Removing ...
Removing http_us2-dl.techpowerup.com_files_GPU-Z.2.59.0.exe_GPU-Z.exe...
Removing https_github.com_rpcs3_rpcs3-binaries-win_releases_download_build-dff7352e2eca04ebdddff21e44c1130dcc13f0aa_rpcs3-v0.0.31-16364-dff7352e_win64.7z...
Deleted: 5 files, 40.9 MB

It is possible that the CMD script has actually never actually been clearing the cache. It explains why I found it to be 14 GB in size when I did so manually.

In any case, it would be nice if the CMD script worked, but also showed the output of cache clearing command, or at least its last line so that we can know how much was removed.

@265785
Copy link

265785 commented Apr 24, 2024

The problem should because the scoop command is directed to the file scoop.cmd, which is also a batch file. Running it will replace and stop scoop_cleanup.cmd, the current batch file. We can use the command call in scoop_cleanup.cmd to solve this problem, like the example below:

(PUSHD "%~DP0")&(REG QUERY "HKU\S-1-5-19">NUL 2>&1)||(powershell -Command "Start-Process '%~sdpnx0' -Verb RunAs"&&EXIT)

@echo on
echo This script will clean the Scoop cache and run the cleanup command.
echo|set/p="Press <ENTER> to continue or CLOSE this window to abort this process"&runas/u: "">NUL
cls
echo Cleaning Scoop cache...
call scoop cleanup --all --global
@echo on
call scoop cache rm --all --global
@echo on
call scoop cleanup --all
@echo on
call scoop cache rm --all
@echo on
echo Done!
pause

Because scoop.cmd contains @echo off command, in order to echo all commands, @echo on is needed to add after each call scoop commands. If it is not needed, just delete them.

The first line of the program above: (PUSHD "%~DP0")&(REG QUERY "HKU\S-1-5-19">NUL 2>&1)||(powershell -Command "Start-Process '%~sdpnx0' -Verb RunAs"&&EXIT) , is to automatically get administrator access. If it is not needed, just delete it.

@marticliment
Copy link
Owner

I did not konw this behaviour, thanks for pointing it out!

@265785
Copy link

265785 commented May 25, 2024

I have already run the example on my PC, it is safe. If you care about the safety and administrator access, Only replace "scoop" with "call scoop" in scoop_cleanup.cmd is also enough.

@echo off
echo This script will clean the Scoop cache and run the cleanup command.
echo|set/p="Press <ENTER> to continue or CLOSE this window to abort this process"&runas/u: "">NUL
cls
echo Cleaning Scoop cache...
call scoop cleanup --all --global
call scoop cache rm --all --global
call scoop cleanup --all
call scoop cache rm --all
echo Done!
pause

The edit is simple for you. However, the scoop_cleanup.cmd still not be updated now, I wonder what are you caring about.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-to-go scoop
Projects
None yet
Development

No branches or pull requests

3 participants