One thing I find helpful when debugging these sort of issues is pry.
If the node you’re running chef-client on has the pry gem installed
and available to chef, you can just include
in your recipe wherever you want to set up a breakpoint – when
chef-client runs, you get dropped into an irb-like shell at that point
in the code where you can inspect variables like node and run
arbitrary code in the context of the compile phase (or in execute
phase if you invoke pry in a ruby_block). Type ‘exit’ and the chef
run will continue. You can even do things like update the node
variable to test that some change you might later make in
attributes.rb will work.
It’s much more convenient than the debug statement/re-upload
strategy that I was using before.
On Thu, Dec 6, 2012 at 11:53 PM, Warren Bain Warren@ninefold.com wrote:
As a chef n00b I get lots of these. The attribute you are referencing doesn’t exist and so node[:sgbase] which is nil doesn’t have a method [:branch]. Hence the slightly confusing error.
direct: +61 2 8221 7729
mobile: +61 414 867 559
Mark J Bradakis email@example.com wrote:
So I get this error:
undefined method `’ for nil:NilClass
Which comes from this line:
627>> revision node[:sgbase][:branch]
Called by a recipe in a file that does this:
“cpan”: “= 1.0.0”,
“apt”: “= 1.0.0”,
“sgbase”: “= 1.0.0”,
“branch”: “= 1.0.0”
sgbase and branch ARE defined - why the NULL error?