The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,803 other followers

Chocolatey: forcing a certain package version and pinning it at that version

Posted by jpluimers on 2021/09/23

For my future self.

Due to an issue with choco-cleaner versions [WayBack] 0.0.6 and [WayBack] 0.0.7, I needed to ensure it was installed as version [WayBack] and keep it that version.

Not sure if this is the canonical way, but this worked:

choco uninstall --yes choco-cleaner
choco install --yes choco-cleaner --version
choco pin add --name=choco-cleaner --version
choco pin list

This worked to revert:

choco pin remove --name=choco-cleaner
choco pin list
choco upgrade --yes choco-cleaner

Aftere this upgrade, choco-cleaner version shows a nice error message when the environment variable %ChocolateyToolsLocation% fails to exist.

In that case calling RefreshEnv.cmd will create that environment variable.



C:\bin\bin>choco upgrade choco-cleaner
Chocolatey v0.10.15
Upgrading the following packages:
By upgrading you accept licenses for the packages.
You have choco-cleaner v0.0.5.2 installed. Version is available based on your source(s).
Progress: Downloading choco-cleaner… 100%
choco-cleaner v0.0.7.1 [Approved]
choco-cleaner package files upgrade completed. Performing other installation steps.
The package choco-cleaner wants to run 'chocolateyinstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll – yes to all/[N]o/[P]rint): y
SUCCESS: The scheduled task "choco-cleaner" was successfully deleted.
PATH environment variable does not have C:\tools\BCURRAN3 in it. Adding…
Refreshing environment variables from the registry for powershell.exe. Please wait…
Adding C:\ProgramData\chocolatey\bin\choco-cleaner.bat and pointing it to powershell command C:\tools\BCURRAN3\choco-cleaner.ps1
SUCCESS: The scheduled task "choco-cleaner" has successfully been created.
Folder: \
TaskName Next Run Time Status
======================================== ====================== ===============
choco-cleaner 1/19/2020 11:00:00 PM Ready
Now configured to run choco-cleaner at 11:00 PM every SUNDAY.
You can manually run choco-cleaner from the Command Prompt and Powershell.
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
The upgrade of choco-cleaner was successful.
Software install location not explicitly set, could be in package or
default install location if installer.
Chocolatey upgraded 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
C:\bin\bin>set | grep -i choco
Path=C:\Program Files\ImageMagick-7.0.9-Q16;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;
C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\bin\bin;C:\Program Files\Mercurial\;;C:\Users\jeroenp\AppData\Local\Programs\Fiddler
Path_HKLM=C:\Program Files\ImageMagick-7.0.9-Q16;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git
\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin
Choco-Cleaner.ps1 v0.0.7.1 (01/16/2020) – deletes unnecessary residual Chocolatey files to free up disk space
Copyleft 2017-2020 Bill Curran ( – free for personal and commercial use
WARNING: $env:ChocolateyToolsLocation not defined.
At C:\tools\BCURRAN3\choco-cleaner.ps1:11 char:98
+ … not defined.' ;throw}
+ ~~~~~
+ CategoryInfo : OperationStopped: (:) [], RuntimeException
+ FullyQualifiedErrorId : ScriptHalted

view raw


hosted with ❤ by GitHub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: