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 1,860 other subscribers

What to do when suddenly some or many .nupkg became zero length and Chocolatey thinks none of them are installed?

Posted by jpluimers on 2024/09/04

A few years back I suddenly had almost all my .nupkg files that Chocolatey uses to track installed software become zero sized.

So I posted a question at [Wayback/Archive] Need help restoring .nupkg files having zero size · Discussion #2765 · chocolatey/choco which got this answer:

It’s a known issue that Chocolatey can’t handle zero size or corrupted .nupkg files.
[Wayback/Archive] #717

So, I’d suggest this:

  1. Writing out a list of commands to run to reinstall the packages. Run the below command, and copy the output to a text file or similar.
Get-ChildItem $env:ChocolateyInstall/lib/*/*.nupkg | % {
    Write-Host "choco install $($_.basename) --skip-powershell"
}
  1. Then delete all of the zero length .nupkg files. There is a oneliner in the linked issue.
  2. Then run the commands copied previously to re-install the packages.

and my remark:

Thanks. This seems to do the job.

Found the on-liner too: #717 (comment)

ChildItem C:\ProgramData\chocolatey\lib\*\*.nu* | where Length -eq 0 | Del

Need to pack for a long weekend now, but will try to combine the two later.

From [Wayback/Archive] If a nupkg/nuspec is corrupt, do not fail trying to read it · Issue #717 · chocolatey/choco:

For those who also encounter this zero size file bug, you can remove them using this PowerShell command.

ChildItem C:\ProgramData\chocolatey\lib\*\*.nu* | where Length -eq 0 | Del

The list I had to reinstall was this:

choco install 7zip --skip-powershell
choco install 7zip.install --skip-powershell
choco install beyondcompare --skip-powershell
choco install choco-cleaner --skip-powershell
choco install chocolatey-compatibility.extension --skip-powershell
choco install chocolatey-core.extension --skip-powershell
choco install chocolatey-dotnetfx.extension --skip-powershell
choco install curl --skip-powershell
choco install dotnet4.7.1 --skip-powershell
choco install dotnetfx --skip-powershell
choco install Everything --skip-powershell
choco install fiddler --skip-powershell
choco install gimp --skip-powershell
choco install git --skip-powershell
choco install git.install --skip-powershell
choco install hg --skip-powershell
choco install imagemagick --skip-powershell
choco install imagemagick.app --skip-powershell
choco install InkScape --skip-powershell
choco install KB2919355 --skip-powershell
choco install KB2919442 --skip-powershell
choco install notepadplusplus --skip-powershell
choco install notepadplusplus.install --skip-powershell
choco install paint.net --skip-powershell
choco install sed --skip-powershell
choco install SourceTree --skip-powershell
choco install sysinternals --skip-powershell
choco install vcredist2010 --skip-powershell

The odd thing is that it would fail, for instance with this:

C:\temp>choco install beyondcompare --skip-powershell
Chocolatey v0.11.3
Installing the following packages:
beyondcompare
By installing, you accept licenses for the packages.
beyondcompare v4.4.2.26348 already installed.
 Use --force to reinstall, specify a version to install, or try upgrade.

Chocolatey installed 0/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Warnings:
 - beyondcompare - beyondcompare v4.4.2.26348 already installed.
 Use --force to reinstall, specify a version to install, or try upgrade.

The solution was to convert from choco install beyondcompare --skip-powershell into choco upgrade beyondcompare.

Odd, but it worked.

–jeroen

Leave a comment

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