could not find filename for attribute .DS_Store in cookbook

The Macintosh workstation saves application states in .DS_Store files. When you edit your Chef cookbooks the MacOS leaves these files in many folders.

When the Chef cookbook is executed, the Chef Client reads all files in the attributes folder and tries to extract values from them. If the .DS_Store file is uploaded with the rest of the cookbook to the Chef server, the Chef cookbook execution stops with the error message:

Recipe Compile Error in /var/chef/cache/cookbooks/…/attributes/.DS_Store

could not find filename for attribute .DS_Store in cookbook …

When you test your cookbook with Test Kitchen, there is no error, so you cannot detect the existence of the file until the Chef cookbook starts to run on the instance.

Even though the.DS_Store file cannot be seen in Finder, it still can be there. It is a hidden file, and even if you enable the display of hidden files, Finder does not show it.

$ cd attributes
$ ls -a
. .. .DS_Store default.rb

To remove the .DS_Store file from the cookbook

  1. Make sure the .DS_Store file is added to the chefignore file
  2. Delete the file from the folder on your workstation
    rm .DS_Store
  3. Increment the version of the cookbook in the metadata.rb file
  4. Upload the new version of the cookbook to the Chef server
    knife cookbook upload MY_COOKBOOK --freeze


Leave a comment

Your email address will not be published. Required fields are marked *