gsandie online notebook

Chef 11 - Libraries and LWRP testing in chef-shell

In chef 11 you can no longer load up the chef-shell, load a cookbook and access the libs and LWRPS that it provides.

You need a few extra steps. Credit to this goes to @btmspox who put this in a CHEF ticket which I can’t current locate.

Testing libs in chef shell, for chef 11 and greater

Start chef shell:

$ chef-shell -c /path/to/chef-config.rb -z

All of the following can be run from chef shell, you don’t need to be in recipe mode:

Chef::Config[:cookbook_path] = "/path/to/your/cookbooks"
run_list = "recipe[partial_search]"
cl =[:cookbook_path])
cookbook_collection =
@events =
node.run_context =, cookbook_collection, @events)
node.run_list =

You can now use partial search from the shell:

partial_search(:node, "chef_environment:production", :keys => { 'fqdn' => ['fqdn'] })