Default search path for cookbook

slayedbylucifer picture slayedbylucifer · Jun 28, 2013 · Viewed 30.6k times · Source

I am a chef Newbie and facing an issue.

Every time I run any of the knife cookbook command, I have to explicitly provide the path to cookbook using -o /path/to/cookbook else it will error out saying no cookbooks found. Please find below commands:

$ knife cookbook upload getting-started
ERROR: Could not find cookbook getting-started in your cookbook path, skipping it
ERROR: Failed to upload 1 cookbook.

$ knife cookbook upload getting-started  -o /home/chefuser/chef11/chef-repo/cookbooks/
Uploading getting-started [0.4.0]
Uploaded 1 cookbook.

Question:

I want to know/list the default search path for cookbooks and need to know how to modify it.

Also, why it is not looking at cookbook path and I have to provide it explicitly?

Thanks.

Answer

Default cookbook path could be set in ~/.chef/knife.rb:

...
cookbook_path [ '~/cookbooks/', '~/base-cookbooks/']
...

Also, you could find knife.rb documentation useful.