How to resolve dependency when running chef client -z

I am running chef-client -z

cookbookname1 has its dependency on other cookbook which has been already added to metadata.rb

but when running chef-client -z , it is giving dependency error as

FATAL: Chef::Exceptions::CookbookNotFound: Cookbook xxxxxx not found. If you're loading xxxxxxxx from another cookbook, make sure you configure the dependency in your metadata

chef client -z doesn’t automatically download dependencies. You need to handle that somehow. One way to do that is to download the dependencies via berks vendor and use —config-option cookbook_path=“<path_to_cookbooks>” when you runchef client -z` to specify a path to the decencies berkshelf downloaded.

You can take a look at some example scripts I use to do this for Linux and Windows here so that I can bootstrap chef on a machine and download cookbooks without needing a chef server set up: https://github.com/TetrationAnalytics/polymath

It’s a variant of what I cover in my videos on Safari, which cover use of client-client in local more more thoroughly (if you happen to have a safari subscription): https://learning.oreilly.com/videos/learning-chef-for/9781491959442 in particular in the “Manage Your Development Environment with Chef” section towards the end of the series.