Had an issue last night with a Chef cookbook that I was developing using Kitchen. The cookbook had been working no problem 2 nights ago and all of the sudden started getting the following error during the Kitchen Converge:
[2017-03-15T18:54:32-07:00] WARN: PowerShell 2.0 is not supported or already installed on this version of Windows: 6.1.7601
================================================================================
Recipe Compile Error in C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/acme_win_web/recipes/default.rb
================================================================================NoMethodError
————-
undefined method `success_codes’ for Chef::Resource::WindowsPackagePlatform:
———
x64-mingw32
The recipe is very simple:
include_recipe 'powershell::powershell5' dsc_resource 'Data_Folder' do resource :file property :destinationpath, 'C:\Data' property :type, 'Directory' end
Being a Chef novice, I spun my wheels on this for many hours. Finally I noticed the Windows cookbook version was “3.0.0” which I hadn’t noticed before and then thought maybe they updated the cookbook. Sure enough they had released 3.0 hours earlier and broken me.
Constrain Cookbook Version
The solution was to instruct Berkshelf to limit the Windows package version by adding a version constraint in the Berksfile and deleting the old Berksfile.lock file:
source 'https://supermarket.chef.io' cookbook 'windows', '< 3.0' metadata [/sourcecode]
This forced Berkshelf to rediscover all the dependencies with the new version constraint. If you forget to delete the lock file you will get an error similar to the following:
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Failed to complete #converge action: [Berkshelf could not find compatible versions for cookbook 'windows':
In Berksfile:
windows (< 3.0.0)In Berksfile.lock:
windows (3.0.0)Try running `berks update windows`, which will try to find 'windows' matching '< 3.0.0'.] on default-w2008r2
Please leave a comment below if this was helpful or you have further questions.