bcurran3 / ChocolateyPackages

My published Chocolatey packages
206 stars 94 forks source link

choco-cleaner changes working directory when run #328

Closed gbloice closed 1 year ago

gbloice commented 1 year ago

Running choco-cleaner from a PowerShell prompt does the expected cleanup but leaves the working directory as C:\ProgramData\chocolately\.chocolatey.

Ideally it should leave the working directory as it was before choco-cleaner was run.

bcurran3 commented 1 year ago

It's not doing that by design. My guess is it's aborting in the middle. v1.0.0 or v1.1.0? choco 1.x or 2.x?

yuakihiro commented 1 year ago

560e484

added Set-Location cause this phenomenon

   Set-Location -Path "$env:ChocolateyInstall\.chocolatey"
gbloice commented 1 year ago

Using Windows Terminal, Powershell 7.3.4

>cd c:\temp choco list choco-cleaner
Chocolatey v2.0.0
choco-cleaner 1.1.0

I've seen this behaviour since choco-cleaner 1.0.0.

FWIW I usually run choco-cleaner straight after running choco upgrade. If I run it again, i.e. on a "cleaned" installation then the working directory isn't changed.

yuakihiro commented 1 year ago

Workaround: use choco-cleaner.bat instead of choco-cleaner.ps1

bcurran3 commented 1 year ago

v1.1.1 eliminates this behavior. CC now deletes the dirs using the full path instead of changing to the .chocolatey dir.

choco install choco-cleaner --version=1.1.1