ScoopInstaller / Scoop

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

[Bug] `scoop uninstall package` followed by `scoop uninstall -p package` #5630

Open Aldo-f opened 1 year ago

Aldo-f commented 1 year ago

Bug Report

Current Behavior

When uninstalling a package without the -p flag i can't remove the persistence data afterward ('bc the package is uninstalled)

Expected Behavior

Doing the same command, but this time with -p, i would like it to remove the persistent data folder

Additional context/output


C:\Users\Aldo
λ scoop uninstall chromium
Uninstalling 'chromium' (116.0.5845.141-r1160321).
Removing shim 'chromium.shim'.
Removing shim 'chromium.exe'.
Removing shortcut ~\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Scoop Apps\Chromium.lnk
Unlinking ~\scoop\apps\chromium\current
'chromium' was uninstalled.

C:\Users\Aldo
λ scoop uninstall -p chromium
ERROR 'chromium' isn't installed.

Possible Solution

Also check if the persistent-directory exists after uninstall, and just remove it by the package-name.

System details

Windows version: 11

OS architecture: 64bit

Additional software: Cmder

Scoop Configuration


{
    "last_update":  "2023-09-03T12:09:24.6725171+02:00",
    "scoop_branch":  "master",
    "scoop_repo":  "https://github.com/ScoopInstaller/Scoop"
}
rashil2000 commented 1 year ago

Hmm, I think this should be solved by introducing a -p flag in the scoop cleanup command, where it will check and delete the persist directory for that application, regardless of its installation state.

Would you like to work on it?

Aldo-f commented 1 year ago

Have never edited a .ps1 file, but will try to make a -p in the scoop-cleanup.ps1 based on what is already written in scoop-uninstall.ps1

But don't have your hopes up for clean code and tests...

All I can promise is that I will have a look at this, probably, small issue. And if I can't manage it I'll let it know.

hagaigold commented 11 months ago

-p flag in scoop cleanup command, where it will check and delete the persist directory for that application, regardless of its installation state.

Delete a persist directory of installed application might break/damage the working state of the application. e.g. pip (package installer) for python.

In my mind, cleanup is a safe operation that you don't need to think too much about the consequences. I agree with @Aldo-f that it should work thru uninstall which it is a "destructive" operation in many context.

rashil2000 commented 11 months ago

I agree with @Aldo-f that it should work thru uninstall which it is a "destructive" operation in many context.

In that case, some check for the -p flag would be required somewhere here and action would be taken accordingly.

https://github.com/ScoopInstaller/Scoop/blob/7b35e19d4cc32eb8cd562559c5a72f488d57a946/libexec/scoop-uninstall.ps1#L43-L45

hagaigold commented 11 months ago

but will try to make a -p in the scoop-cleanup.ps1

@Aldo-f, I can make PR for this one