Upgrading a Chef cookbook with Berkshelf

- [2 mins read]

I just upgraded my chef-clients via the omnibus_updater cookbook when things started breaking: [2016-02-18T21:41:13+02:00] WARN: Current  apt_package[apt-transport-https]: /var/chef/cache/cookbooks/datadog/recipes/repository.rb:24:in `from_file'   ================================================================================   Recipe Compile Error in /var/chef/cache/cookbooks/chef-wrapper-omnibus-updater/recipes/default.rb   ================================================================================   NameError   ---------   uninitialized constant Chef::REST   Cookbook Trace:   ---------------     /var/chef/cache/cookbooks/omnibus_updater/libraries/omnitrucker.rb:84:in `url'     /var/chef/cache/cookbooks/omnibus_updater/recipes/downloader.rb:27:in `from_file'     /var/chef/cache/cookbooks/omnibus_updater/recipes/default.rb:25:in `from_file'     /var/chef/cache/cookbooks/chef-wrapper-omnibus-updater/recipes/default.rb:27:in `from_file'   Relevant File Content:   ----------------------   /var/chef/cache/cookbooks/omnibus_updater/libraries/omnitrucker.rb:    77:        if(url_or_node.is_a?(Chef::Node))    78:          url = build_url(url_or_node)    79:          node = url_or_node    80:        else    81:          url = url_or_node    82:          raise "Node instance is required for Omnitruck.url!" unless node    83:        end    84>>       request = Chef::REST::RESTRequest.new(:head, URI.parse(url), nil)    85:        result = request.call    86:        if(result.kind_of?(Net::HTTPRedirection))    87:          result['location']    88:        end    89:      end    90:    91:    end    92:  end    93:

Googling for uninitialized constant Chef::REST only yielded some results from March 2013, so I decided to upgrade the omnibus_updater cookbook from 1.0.4. to 1.0.6 by editing metadata.rb. I bumped the dependency version as well as my wrapper cookbook version, but when I ran berks install, I got the following:

Resolving cookbook dependencies...
Fetching 'chef-wrapper-omnibus-updater' from source at .
Fetching cookbook index from https://supermarket.chef.io...
Unable to satisfy constraints on package omnibus_updater due to solution constraint (omnibus_updater = 1.0.4). Solution constraints that may result in a constraint on omnibus_updater: [(chef-wrapper-omnibus-updater = 0.1.2) -> (omnibus_updater ~> 1.0.6)], [(omnibus_updater = 1.0.4)]
Demand that cannot be met: (omnibus_updater = 1.0.4)
Artifacts for which there are conflicting dependencies: omnibus_updater = 1.0.4 -> []Unable to find a solution for demands: chef-wrapper-omnibus-updater (0.1.2), omnibus_updater (1.0.4)

That at least had some Google results, ends up that I need to upgrade via berks update omnibus_updater instead of just incrementing the version number. After the upgrade, the other issue was also resolved.

comments powered by Disqus