33

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.

slayedbylucifer
  • 22,878
  • 16
  • 94
  • 123

1 Answers1

37

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

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

Also, you could find knife.rb documentation useful.

codeforester
  • 39,467
  • 16
  • 112
  • 140
  • Can't thank you enough!! It saved me a lot of unnecessary typing. – slayedbylucifer Jun 28 '13 at 11:09
  • 2
    This answer would benefit by specifying where knife.rb is located. – Travis Bear Jan 21 '14 at 21:36
  • 4
    `knife.rb` can be found in the .chef folder of either your home directory, or the directory where your `cookbooks/` folder is, depending on how you set Chef up. If you don't have a `.chef/knife.rb`, you didn't run `knife configure --initial`. See the instructions [here](https://www.digitalocean.com/community/tutorials/how-to-install-a-chef-server-workstation-and-client-on-ubuntu-vps-instances#WorkstationInstallation) for more details on how to initialize your workstation for Chef. – spiffytech Jul 30 '14 at 15:02
  • 2
    This blog has a better cookbook_path setup, i.e. the way you would expect it to work: https://www.coveros.com/setting-your-knife-rb-cookbook_path-to-match-your-cookbook-locations/ – cbron Sep 16 '15 at 21:49
  • From @cbron link: setting `cookbook_path [ '.', '..','~/cookbooks/']` will look in local and parent directory for a match first. – 79E09796 Mar 16 '16 at 12:25