chocolatey / cChoco

Community resource to manage Chocolatey
Apache License 2.0
154 stars 99 forks source link

cChocoPackageInstaller with AutoUpgrade enabled continuously drifts #165

Closed dappleby300 closed 2 years ago

dappleby300 commented 2 years ago

Hi,

When using the cChocoPackageInstaller with AutoUpgrade set to $true the testing code continusly causes drifts due to the handling of the source parameter.

Version: Chocolatey v1.0.1 OS: Windows Server 2019

cChoco Module version: 2.5.0.0

Powershell:

Name                           Value
----                           -----
PSVersion                      5.1.17763.2268
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.2268
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

DSC trace log;

VERBOSE: [TEST-SERVER]: LCM:  [ Start  Resource ]  [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome]
VERBOSE: [TEST-SERVER]: LCM:  [ Start  Test     ]  [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome]
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Start Test-TargetResource
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Test-ChocoInstalled
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Env:Path contains: C:\Program Files (x86)\AdoptOpenJDK\jdk-8.0.292.10-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;;c:\WINDOWS\System32\WBem;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files (x86)\Silk\SilkTest;C:\Program Files (x86)\Silk\SilkTest\ng\gui
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Test-Command choco
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] choco exists
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] YES - Choco is Installed
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Start IsPackageInstalled GoogleChrome
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Path variables: C:\Program Files (x86)\AdoptOpenJDK\jdk-8.0.292.10-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;;c:\WINDOWS\System32\WBem;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files (x86)\Silk\SilkTest;C:\Program Files (x86)\Silk\SilkTest\ng\gui
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Finding packages -eq GoogleChrome
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Found 1 matching packages
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Found: GoogleChrome with version 101.0.4951.41
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Checking if GoogleChrome is installed
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Testing if GoogleChrome can be upgraded
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Testing if GoogleChrome can be upgraded: 'choco upgrade GoogleChrome --noop --source="-pSource"sys-Baseline""'
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Chocolatey v1.0.1
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] _ Chocolatey:ChocolateyUpgradeCommand - Noop Mode _
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] GoogleChrome was not found with the source(s) listed.
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome]  If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome]  Version: ""; Source(s): "-pSource sys-Baseline"
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Chocolatey can upgrade 0/1 packages.
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome]  See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] Warnings:
VERBOSE: [TEST-SERVER]:                            [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome]  - GoogleChrome - GoogleChrome was not found with the source(s) listed.
VERBOSE: [TEST-SERVER]: LCM:  [ End    Test     ]  [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome] False in 1.1990 seconds.
VERBOSE: [TEST-SERVER]: LCM:  [ End    Resource ]  [[cChocoPackageInstaller]GoogleChrome::[tag_chrome]tag_chrome]

The main issue is with the upgrade test line. The source value of "-pSource"sys-Baseline" causes it to fail.

'choco upgrade GoogleChrome --noop --source="-pSource"sys-Baseline""'

See below;

 choco upgrade GoogleChrome --noop --source="-pSource"sys-Baseline""
Chocolatey v1.0.1
_ Chocolatey:ChocolateyUpgradeCommand - Noop Mode _

GoogleChrome was not found with the source(s) listed.
 If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.
 Version: ""; Source(s): "-pSourcesys-Baseline"

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

Warnings:
 - GoogleChrome - GoogleChrome was not found with the source(s) listed.

Adjusting the source option to remove the "-pSource" bit fixes the issue;

choco upgrade GoogleChrome --noop --source="sys-Baseline"
Chocolatey v1.0.1
_ Chocolatey:ChocolateyUpgradeCommand - Noop Mode _
GoogleChrome v101.0.4951.41 is the latest version available based on your source(s).

Chocolatey can upgrade 0/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
dappleby300 commented 2 years ago

This issue can be closed. It is fixed in 2.5.0.0 but my code was still loading the old 2.4.0.0 module.