bcurran3 / ChocolateyPackages

My published Chocolatey packages
207 stars 93 forks source link

choco-cleaner error while filling `$GotCacheFiles`: `ChildItem : Access is denied` `At C:\tools\bcurran3\choco-cleaner.ps1:119 char:18` #315

Closed jpluimers closed 1 year ago

jpluimers commented 1 year ago

I got this on one system that has v0.0.8.4 of choco-cleaner installed. None of my other systems with the same version show this error.

I need to investigate this further to see if what differences there are between these systems.

Just posting this so you know this error is happening "in the wild".

Log:

Choco-Cleaner.ps1 v0.0.8.4 (05/28/2021) - deletes unnecessary residual Chocolatey files to free up disk space
Copyleft 2017-2021 Bill Curran (bcurran3@yahoo.com) - free for personal and commercial use

Choco-Cleaner Summary:
  **  NO unnecessary Chocolatey .ignore files to delete.
  **  NO unnecessary Chocolatey .old files to delete.
ChildItem : Access is denied
At C:\tools\bcurran3\choco-cleaner.ps1:119 char:18
+      $GotCacheFiles=ChildItem -Path $ENV:tmp\chocolatey -Recurse
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetChildItemCommand

  **  NO unnecessary Chocolatey cache files (C:\Users\jeroenp\AppData\Local\Temp\chocolatey) to delete.
  **  NO unnecessary Chocolatey cache files (C:\WINDOWS\temp\chocolatey) to delete.
  **  NO unnecessary Chocolatey config backup file to delete.
  **  NO unnecessary Chocolatey package embedded archive files in toolsDir to delete.
  **  Deleting unnecessary Chocolatey package embedded archives and executables in .nupkg files...
  **  NO unnecessary Chocolatey package embedded Microsoft installers to delete.
  **  NO unnecessary Chocolatey package embedded various read me files to delete.
  **  NO unnecessary Chocolatey orphaned shim files to delete.
Choco-Cleaner finished deleting unnecessary Chocolatey files and reclaimed ~ 0 KB!
Found Choco-Cleaner.ps1 useful?
Buy me a beer at https://www.paypal.me/bcurran3donations
Become a patron at https://www.patreon.com/bcurran3
bcurran3 commented 1 year ago

This happens when the running account doesn't have permissions to delete a directory or file. You just need to change the permissions or manually delete the file(s).

New version up for testing as of yesterday: choco install choco-cleaner --pre

It doesn't address the issue you had, but I would appreciate any feedback on it before it's officially released.

bcurran3 commented 1 year ago

p.s. I think at one time I had those message not displayed, but later decided it's better to know about the files to go manually delete or reset permission.