Chef recipe error: Error Resolving Cookbooks for Run List

12.5k Views Asked by At

I have installed the following cookbooks via knife:

for cb in apt build-essential erlang java sysctl git ulimit yum yum-epel packagecloud riak curl ; do knife cookbook site install $cb; done;

And now when I run sudo chef-client --local-mode --runlist 'recipe[riak]' I get an error complaining about the git dependency. However, the riak cookbook contains "git": "~> 3.0",.

The git cookbook that's installed is this version:

$ cat /root/chef-repo/cookbooks/git/metadata.rb | grep version
version           '4.0.2'

Here is the actual error for the command:

$ sudo chef-client --local-mode --runlist 'recipe[riak]'
Starting Chef Client, version 11.18.0.rc.1
resolving cookbooks for run list: ["riak"]

================================================================================
Error Resolving Cookbooks for Run List:
================================================================================

Missing Cookbooks:
------------------
Could not satisfy version constraints for: git

Expanded Run List:
------------------
* riak


Running handlers:
[2014-11-15T01:48:55-05:00] ERROR: Running exception handlers
Running handlers complete
[2014-11-15T01:48:55-05:00] ERROR: Exception handlers complete
[2014-11-15T01:48:55-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 3.588961624 seconds
[2014-11-15T01:48:55-05:00] ERROR: 412 "Precondition Failed "
[2014-11-15T01:48:55-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
root@test:~/chef/cookbooks/test# 

Lastly here is the stacktrace if that's actually helpful to someone:

$ cat /var/chef/cache/chef-stacktrace.out
Generated at 2014-11-15 01:48:55 -0500
Net::HTTPServerException: 412 "Precondition Failed "
/opt/chefdk/embedded/lib/ruby/2.1.0/net/http/response.rb:119:in `error!'
/opt/chefdk/embedded/apps/chef/lib/chef/http.rb:145:in `request'
/opt/chefdk/embedded/apps/chef/lib/chef/http.rb:126:in `post'
/opt/chefdk/embedded/apps/chef/lib/chef/policy_builder/expand_node_object.rb:168:in `sync_cookbooks'
/opt/chefdk/embedded/apps/chef/lib/chef/policy_builder/expand_node_object.rb:66:in `setup_run_context'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:265:in `setup_run_context'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:429:in `do_run'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:213:in `block in run'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:207:in `fork'
/opt/chefdk/embedded/apps/chef/lib/chef/client.rb:207:in `run'
/opt/chefdk/embedded/apps/chef/lib/chef/application.rb:236:in `run_chef_client'
/opt/chefdk/embedded/apps/chef/lib/chef/application/client.rb:338:in `block in run_application'
/opt/chefdk/embedded/apps/chef/lib/chef/application/client.rb:327:in `loop'
/opt/chefdk/embedded/apps/chef/lib/chef/application/client.rb:327:in `run_application'
/opt/chefdk/embedded/apps/chef/lib/chef/application.rb:55:in `run'
/opt/chefdk/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
/usr/bin/chef-client:33:in `load'
/usr/bin/chef-client:33:in `<main>

Any help is greatly appreciated.

3

There are 3 best solutions below

2
On BEST ANSWER

The constraint "git": "~> 3.0" means that it wants a version >= 3.0 and less than 4.0.

That is not satisfied by "4.0.2".

Reference:

0
On

knife cookbook site install doesn't actually grok versions of dependencies. It is an older tool that predates much of how modern cookbooks do dependencies. I recommend you use Berkshelf to manage your dependencies instead, it handles this kind of thing correctly.

To explain the issue in more detail, the ~> 3.0 constraint means anything from 3.0 up to but not including 4.0. knife cookbook site install just grabbed the latest version of the git cookbook which is 4.0.2, and thus outside the allowable range.

0
On

When you create a cookbook it creates a folder named nodes. In this folder there is a json file with the names of the cookbook. Delete this folder and try again. It worked for me.