Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade does not properly update metadata everywhere #144

Open
zeusttu opened this issue Mar 2, 2020 · 0 comments
Open

Upgrade does not properly update metadata everywhere #144

zeusttu opened this issue Mar 2, 2020 · 0 comments
Labels

Comments

@zeusttu
Copy link

zeusttu commented Mar 2, 2020

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 chocolatey package 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.install package
  • Run the Chocolatey cookbook with the following attributes:
    node['chocolatey']['upgrade'] = true
    node['chocolatey']['install_vars']['chocolateyVersion'] = '0.10.15' # newest version at time of writing of this issue
    
    This will update Chocolatey to the latest version while leaving some stray metadata from the old version.
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants