-
Notifications
You must be signed in to change notification settings - Fork 76
Description
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:
- Install any version of Chocolatey.
- Use Chocolatey itself (not the cookbook or the installation script) to upgrade or downgrade the
chocolateypackage to a non-latest version (say 0.10.12). This will create some package metadata not created by Chocolatey's install script. - Install version 2.25.0 of the
git.installpackage - Run the Chocolatey cookbook with the following attributes:
This will update Chocolatey to the latest version while leaving some stray metadata from the old version.
node['chocolatey']['upgrade'] = true node['chocolatey']['install_vars']['chocolateyVersion'] = '0.10.15' # newest version at time of writing of this issue - Try to update Git with the following Chef resource:
chocolatey_package 'git.install' do action :upgrade version `2.25.1' end
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.