Chef client execution of multiple recipes

Hello Chef Gurus,
I am a newbie to chef automation and stuck with an issue. I have a cookbook two recipes with one recipe creating a folder and store a file into it and the second recipe reads from this file. I have added the recipes in a run list in the order.

When I execute the run_list, chef-client throws the error with second recipe saying that the file does not exist, which is supposed to be created by the first recipe.

Is there a way to avoid this error, as the file has to be created on bootstrap and should be created before the cookbook execution

Babu G

I assume you’re being hit by the two-pass problem in your recipe code.

See and for insight about it.

Thanks Tensi for your valuable comment. I modified my script as per the document suggested but still same error is happening. Following is the modified ruby block .

file ‘/u01/app/paas/keys/’ do
vmPublicKeyText ="/u01/app/paas/keys/")
only_if { File.exist?(’/u01/app/paas/keys/’) }
puts vmPublicKeyText

As I said earlier, the “” file is created by a recipe before the current recipe.
Please check my ruby block and correct me if anything went wrong,

Issue resolved after creating a ruby_block on top of my actual code. Thanks a lot again for your help