Chef error NoMethodError – nil:NilClass

Had several times the error from below

NoMethodError
————-
undefined method `[]’ for nil:NilClass

and each time I forgot which was the root cause.

What’s happening is that Chef can’t find some attributes, or some array of attributes that it needs to successfully converge the cookbook.

Run the converge in debug mode: kitchen converge -l=DEBUG and on the first line containing the error, see at what .rb files it points, including the line number, and you’ll discover what attributes you’re missing from the cookbook

Update: Another form of this error that I’ve encountered was

NoMethodError
————-
private method `select’ called for nil:NilClass

and this was happening when using artifact_deploy resource from artifact cookbook.
What was really causing the problem was the fact that I was specifying a deploy_to location that was not existing (set to drive D:, when the virtual machine had only a C: drive)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: