Does pry-byebug (or any other interactive debugger) work with cookbook recipes when chef-client runs?

I put this code in cookbook recipe. It runs, but does not break/stop in interactive pry console.

require ‘pry-byebug’ ; binding.pry

Any thoughts or resources you can point me to?

I just want to be able to inspect/view values to all attributes I see in recipe/etc without ‘put’ statements.
LOG=debug does not give me that kind of detail. Is there something more comprehensive?

Thank You,
Phil Walker

Yes, this works as you would expect. I think we even include it with the Chef installers now, though that might just be ChefDK, I forget. One place it doesn’t work well is inside Test Kitchen though, as that doesn’t give you an interactive SSH session.

Hi philw-chef,

LOVE Pry, it’s an awesome addition to your Ruby toolboox and works well when debugging Chef cookbooks for the reasons you have described and way better than outputting the state of the compile/converge into Chef::Log or using puts.

For stepping through resources at a higher level and determining where attribute values have come from I’ve also used chef-shell in conjunction with Shef extras, at development time though pry seems to do it all. One plus for chef-shell is that if you use the breakpoint resource and accidentally leave it in, it is ignored when the cookbook is run with chef-client. Leaving a pry breakpoint in a cookbook means you could be in for a long wait!

One thing I’ve thought about using with test kitchen is DRb (Distributed Ruby) which is what I think kitchen-binding uses (or pry-remote), again never used kitchen-binding or DRb in this context but would be interested to hear if others have used it.

Happy debugging!

Thanks guys.

I believe my situation may be similar to a test-kitchen scenario. I am using chef-client, chef-provisioning with vagrant and virtual box for local VM development and testing. My deployment/provisioning just runs without stopping or breaking for me to debug and step through recipe.

I think I’m going to give pry-remote a try. I will also look at chef-shell and Shef extras.

If you know of any resources, presentations, etc. for pry-remote, chef-shell, and Shef let me know. In the meantime I will goole search for “how-tos.”

Thanks again.

I’m having the same issue, where pry is unable to load the console shell. It’s stop at the binding.pry, but console shell is not loaded, just blank screen.

No luck with pry-remote, either. Using, kitchen with vagrant setup as well.

Were you able to get your debug going?

Unfortunately the SSH support in test kitchen doesn’t allow for this. Pry does work as per normal with chef itself or with chefspec unit tests.