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] scoop cleanup: add option for closing running apps to avoid "PermissionDenied" when apps are still running #5852

Open
soredake opened this issue Mar 27, 2024 · 1 comment

Comments

@soredake
Copy link

soredake commented Mar 27, 2024

Feature Request

Is your feature request related to a problem? Please describe.

When you are cleaning old versions that are still running, you will receive "Remove-Item : Cannot remove item" error.

To reproduce this:

  1. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  2. Invoke-RestMethod -Uri https://get.scoop.sh/ | Invoke-Expression
  3. scoop install git
  4. scoop bucket add extras
  5. scoop install syncthingtray@1.4.13
  6. run syncthing tray
  7. scoop install syncthingtray@1.5.0
  8. scoop cleanup -a -k
  9. error:
Remove-Item : Cannot remove item C:\Users\ruruo\scoop\apps\syncthingtray\1.4.13\syncthingtray.exe: Access to the path
'syncthingtray.exe' is denied.
At C:\Users\ruruo\scoop\apps\scoop\current\libexec\scoop-cleanup.ps1:50 char:9
+         Remove-Item $dir -ErrorAction Stop -Recurse -Force
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (syncthingtray.exe:FileInfo) [Remove-Item], UnauthorizedAccessExceptio
   n
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand

Related: #2035

Describe the solution you'd like

Add option to scoop cleanup for closing running apps to avoid "PermissionDenied" when apps are still running.

Describe alternatives you've considered

Not having such option.

@soredake
Copy link
Author

Would be nice if this code can be adapted for cleanup command

Scoop/lib/install.ps1

Lines 1147 to 1165 in d337bb1

# test if there are running processes
function test_running_process($app, $global) {
$processdir = appdir $app $global | Convert-Path
$running_processes = Get-Process | Where-Object { $_.Path -like "$processdir\*" } | Out-String
if ($running_processes) {
if (get_config IGNORE_RUNNING_PROCESSES) {
warn "The following instances of `"$app`" are still running. Scoop is configured to ignore this condition."
Write-Host $running_processes
return $false
} else {
error "The following instances of `"$app`" are still running. Close them and try again."
Write-Host $running_processes
return $true
}
} else {
return $false
}
}

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

No branches or pull requests

1 participant