sous-chefs/logrotate

had an error: NoMethodError: undefined method `declared_type=' for Chef::Resource::Directory

witsriram opened this issue · 5 comments

I m using version 2.1.0, Things were good with version 1.9.2, since new release we are facing the issue,

Cookbook Trace:
---------------
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb:58:in build' /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb:109:inbuild_resource'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb:67:in declare_resource' /var/chef/cache/cookbooks/logrotate/resources/app.rb:60:inblock in class_from_file'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in instance_eval' /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:incompile_and_converge_action'

NoMethodError
-------------
undefined method `declared_type=' for Chef::Resource::Directory

logrotate_app 'nginx' do
cookbook 'logrotate'
path '/var/log/nginx/*.log'
frequency 'weekly'
rotate 4
create '644 root root'
end

Thanks for the report. The stack trace looks like it is in the middle of the compat_resource library. To help investigate: what version of chef are you using?

I m using version 12.0.1

After some investigation it appears that this cookbook currently supports version 12.1.0+. The limitations on the versioning I've found are:

  • The compat_resource cookbook only supports 12.0.3+.
  • The Chef::Log.deprecation is called called for deprecated options and this was added in 12.1.0

I can clear up the second point by adding some guards around it, but judging from the history in the compat_resource fixing the hard requirement on 12.0.3+ might be not be straightforward.

In the near term, you may unfortunately need to pin to 1.9.2 of the logrotate cookbook or upgrade to 12.1.0+.

Thank you. I will upgrade to 12.1.0+.

Closing this out as 12.1.0 is rather old now and I am about to bump the required version to 12.5+. Thanks for reporting it, I hope the upgrade worked for you.