chocolatey-community / chocolatey-cookbook

Chef cookbook to install chocolatey and packages on Windows
Apache License 2.0
108 stars 77 forks source link

Upgrade does not properly update metadata everywhere #144

Open zeusttu opened 4 years ago

zeusttu commented 4 years ago

Cookbook version

2.0.1

Chef-client version

Tested with both Chef 14 and Chef 15.

Platform Details

Windows 10 on AWS

Scenario and diagnosis

After upgrading Chocolatey from 0.10.12 (which was installed by the Chocolatey package manager itself) to 0.10.15 by running the Chocolatey cookbook with node['chocolatey']['upgrade'] set to true, an upgrade of git.install from 2.25.0 to 2.25.1 will fail with the following error message:

Already referencing a newer version of 'chocolatey'.

Upon inspection of the system, I find a NuSpec for the Git package in <choco_home>\lib\git.install\git.install.nuspec which says that Chocolatey 0.10.12 is still installed, yet choco list -lo lists version 0.10.15 for the chocolatey package. It looks like the dependency resolution procedure picks up mixed signals about which Chocolatey version is installed, gets confused and errs out.

I found that a choco upgrade chocolatey --version 0.10.15 --force (which re-installs the already installed version) resolves the issue.

Steps to Reproduce:

Expected Result:

Git is updated to version 2.25.1.

Actual Result:

The aforementioned error occurs:

Already referencing a newer version of 'chocolatey'.

Workaround

Do not set node['chocolatey']['upgrade'] to true, but instead add a chocolatey_package 'chocolatey' resource to update Chocolatey in your Chef cookbooks. This works well and has no negative side-effects as far as I can tell, but I listed it as a workaround because it requires people to circumvent the Chocolatey cookbook to do something that's advertised as a capability of the Chocolatey cookbook.

Proposed solution

Use the chocolatey_package resource to update Chocolatey from within the Chocolatey cookbook (so basically incorporate the "workaround" into the Chocolatey cookbook itself). I have seen this same solution being hinted at by issue #12.