Open DevonBritton opened 3 years ago
I am seeying the exact same behaviour, during uninstall the chocoinstalled.xml is removed, and 1~3 seconds after the dsc state fails the file is recreated.
Hello,
We are encountering the same issue when upgrading OpenJDK. Partial contained 11.0.8.1 before. When set to 11.0.14.1, the upgrade process runs succesfully (installer exits 0). However a second later we receive the same missing XML error
We need steps to reproduce this before it can be looked at, including sample code.
I just encountered the same error when upgrading the pnpm
package from version 7.11.0 to 7.13.0. Here is the relevant part of Start-DscConfiguration output:
2022-10-03T18:29:25.2480640Z output Chocolatey v1.1.0 Uninstalling the following packages: pnpm pnpm v7.11.0 Skipping auto uninstaller - No registry snapshot. pnpm
2022-10-03T18:29:25.2482539Z has been successfully uninstalled. Chocolatey uninstalled 1/1 packages. See the log for details
2022-10-03T18:29:25.2484323Z (C:\ProgramData\chocolatey\logs\chocolatey.log).
2022-10-03T18:29:25.2504410Z VERBOSE: [BLDSVR003]: [[cChocoPackageInstaller]pnpm::[mChocolateyPackages]ChocoPackages] Re-Installing pnpm with
2022-10-03T18:29:25.2507807Z correct version 7.13.0
2022-10-03T18:29:25.2613140Z VERBOSE: [BLDSVR003]: [[cChocoPackageInstaller]pnpm::[mChocolateyPackages]ChocoPackages] Install command: 'choco
2022-10-03T18:29:25.2615986Z install pnpm -y --version="7.13.0" --no-progress'
2022-10-03T18:29:42.0063254Z VERBOSE: [BLDSVR003]: [[cChocoPackageInstaller]pnpm::[mChocolateyPackages]ChocoPackages] Package output
2022-10-03T18:29:42.0065037Z Chocolatey v1.1.0 Installing the following packages: pnpm By installing, you accept licenses for the packages. pnpm v7.13.0 pnpm package
2022-10-03T18:29:42.0067494Z files install completed. Performing other installation steps. Downloading pnpm from
2022-10-03T18:29:42.0068632Z 'https://github.com/pnpm/pnpm/releases/download/v7.13.0/pnpm-win-x64.exe' Download of pnpm.exe (40.6 MB) completed. Hashes match.
2022-10-03T18:29:42.0071268Z C:\ProgramData\chocolatey\lib\pnpm\tools\pnpm.exe ShimGen has successfully created a shim for pnpm.exe The install of pnpm was
2022-10-03T18:29:42.0072502Z successful. Software install location not explicitly set, it could be in package or default install location of installer. Chocolatey
2022-10-03T18:29:42.0074960Z installed 1/1 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
2022-10-03T18:29:42.3851997Z Cannot find path 'C:\ProgramData\chocolatey\cache\ChocoInstalled.xml' because it does not exist.
2022-10-03T18:29:42.3863645Z + CategoryInfo : ObjectNotFound: (C:\ProgramData\...coInstalled.xml:) [], CimException
2022-10-03T18:29:42.3866598Z + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
2022-10-03T18:29:42.3869360Z + PSComputerName : BLDSVR003.mycompany.com
2022-10-03T18:29:42.3872158Z
2022-10-03T18:29:42.3897464Z VERBOSE: [BLDSVR003]: LCM: [ End Set ] [[cChocoPackageInstaller]pnpm::[mChocolateyPackages]ChocoPackages] in 25.1310 seconds.
2022-10-03T18:29:42.4014463Z The PowerShell DSC resource '[cChocoPackageInstaller]pnpm::[mChocolateyPackages]ChocoPackages' with SourceInfo '::2::2::cChocoPackageInstal
2022-10-03T18:29:42.4017618Z ler' threw one or more non-terminating errors while running the Set-TargetResource functionality. These errors are logged to the ETW channe
2022-10-03T18:29:42.4020597Z l called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
Here is the configuration fragment:
cChocoPackageInstall pnpm
{
Name = 'pnpm'
Ensure = 'Present'
Version = '7.13.0' # the error happens when upgrading from a previous version
}
We are specifying the exact pnpm package version (using the Version
property on the cChocoPackageInstaller resource), so the resource uninstalls the previous version and installs the specified one (instead of doing it in one go via "choco upgrade"). The new package version installs successfully, but the resource encounters an error.
The culprit seems to be this line in cChocoPackageInstall.psm1:
Remove-Item $ChocoInstallList -Force
This will fail if the file does not exist (and the function does not check for it). When Version
is specified, the resource calls UninstallPackage
(which deletes the file) and InstallPackage
(which attempts to delete the file again).
The fix would be to either add an existence check (but that would still not be 100% reliable due to race conditions) or simply -ErrorAction SilentlyContinue
.
This happens when the resource is called with the Version parameter set, but a different version is already installed.
See cChocoPackageInstall.psm1 - Set-TargetResource The ChocoInstalled.xml cache file is created at the beginning of Set-TargetResource by a call to IsPackageInstalled (line 97). If the result is true and "Version" is specified, it is assumed that the incorrect version is installed (Test-TargetResource would have returned false), so Set-TargetResource calls UninstallPackage, which deletes the ChocoInstalled.xml file. Then InstallPackage is called, which again tries, and fails, to delete the ChocoInstalled.xml file again.
choco install notepadplusplus --version=8.5.8
Invoke-DscResource -ModuleName 'cChoco' -Name 'cChocoPackageInstaller' -Method 'Set' -Property @{
Name='notepadplusplus'
Version='8.6.5'
Ensure='Present'
} -Verbose
If instead, you use MinimumVersion, the package is upgraded instead of being uninstalled/installed. Of course, this has the side effect of not downgrading packages if that is the desire.
Invoke-DscResource -ModuleName 'cChoco' -Name 'cChocoPackageInstaller' -Method 'Set' -Property @{
Name='notepadplusplus'
MinimumVersion='8.6.5'
Ensure='Present'
} -Verbose
Hi,
Any update regarding this issue? This is still happening. We've added retries to prevent failing pipelines.
Thank you
There is no update on this at the moment. For transparency we have not prioritised this issue.
If this is an issue for you, have you looked at the Chocolatey DSC resource?
Hi there.
Recently the DSC process which had been running smoothly began failing due to the below error:
I have seen that the "chocoinstalled.xml" file is being created in the correct location, but then deleted before the DSC process is completed causing it to fail. I've also noticed that the step that's failing is taking longer than the previous steps to run and I'm not sure if that might be the issue?
Any assistance would be appreciated.
Kind Regards, Devon Britton.