# Custom cookbook generator

#1

I am a beginner with custom chef generators, hopefully i can describe my issue and see if someone can make sense of this.

I used the command: chef generate generator my_generator

which worked well, then i ran chef gem install chef-flavor-pan

and i added chefdk.generator_cookbook "\path\to\custom_generator" to my knife.rb

All of that worked just fine, and when i went to use the custom generator, i would get the error below:

\$ chef generate cookbook my_cookbook
[2016-07-19T13:54:26-05:00] WARN: Found a directory drone_ci in the cookbook path, but it contains no cookbook files. skipping.
ERROR: Chef failed to converge: Cookbook loaded at path(s) [/Users/userID/development/completely_unrelated_cookbook] has invalid metadata: The name' attribute is required in cookbook metadata


And i had to add the name attribute to a completely unrelated cookbook before it would run the generator, Does it scan your hard drive for all possible cookbooks, and make sure they are valid before generating new cookbooks? is there a setting somewhere i am missing? There isn’t much for documentation on google about custom generators. So i apologize if this is kind of a noob question.

Under the hood, the generator is just a Chef Solo run*, so it ends up loading the metadata for all the cookbooks in the same directory. The expectation is that you’d put your generator somewhere in your .chef directory away from other cookbooks because the generator is somewhat special.