NoMethodError, what does this mean?



Im trying to update the php.ini file on my system. There's only two small changes
I want to make so I thought I would copy the file over to my templates directory and just add a couple variables in there to replace the values I want, and just overwrite the php.ini file. The only thing is I'm getting this error every time I try to apply the recipe.

Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * template[/etc/php/7.2/apache2/php.ini] action create

    Error executing action `create` on resource 'template[/etc/php/7.2/apache2/php.ini]'

    undefined method `preferred_filename_on_disk_location' for nil:NilClass

    Resource Declaration:
    # In update_php_file.rb

     10: template '/etc/php/7.2/apache2/php.ini' do
     11: 	action :create
     12: 	mode '0644'
     13: 	source 'php.erb'
     14: 	variables(
     15: 		:post_size =>  '12M',
     16: 		:upload_size =>  '10M'
     17: 		)
     18: end

    Compiled Resource:
    # Declared in update_php_file.rb:10:in `run_chef_recipe'

    template("/etc/php/7.2/apache2/php.ini") do
      action [:create]
      default_guard_interpreter :default
      source "php.erb"
      declared_type :template
      cookbook_name "(chef-apply cookbook)"
      recipe_name "(chef-apply recipe)"
      mode "0644"
      variables {:post_size=>"12M", :upload_size=>"10M"}
      path "/etc/php/7.2/apache2/php.ini"
      owner nil
      group nil
      verifications []

    System Info:
    ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]

[2019-05-09T14:35:34-03:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2019-05-09T14:35:34-03:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-05-09T14:35:34-03:00] FATAL: NoMethodError: template[/etc/php/7.2/apache2/php.ini] ((chef-apply cookbook)::(chef-apply recipe) line 10) had an error: NoMethodError: undefined method `preferred_filename_on_disk_location' for nil:NilClass

I'm not sure what this means, and I literally can't find anything explaining it. Any feedback would be appreciated. (I'll post the recipe contents below)

template '/etc/php/7.2/apache2/php.ini' do
action :create
mode '0644'
source 'php.erb'
:post_size => '12M',
:upload_size => '10M'


The core problem here is the usage of chef-apply which is a limited subset that is primarily useful for toy examples and does not have feature parity with chef-client.


I'm just trying to run this on the local server to test it before I upload it to the chef server and run it on the nodes, but I still can't get it to work. Is there a specific way to pull an attribute from the default.rb with the recipe and apply it to a template? thanks in advance.


I've found this book online:"undefined+method+'preferred_filename_on_disk_location'+for+nil:NilClass"&source=bl&ots=QXm5PfL8Gy&sig=ACfU3U1z-pUUMJyJIIbuq9Lm5Nri0-9Tnw&hl=en&sa=X&ved=2ahUKEwjB96uTjZniAhUineAKHRaKCSkQ6AEwB3oECAkQAQ#v=onepage&q="undefined%20method%20'preferred_filename_on_disk_location'%20for%20nil%3ANilClass"&f=false

It basically says to avoid using chef-apply when working with multiple ruby files and use chef-solo in order to apply the cookbooks/recipes. It says there is no way for the file to access the data in the template when using chef-apply.


It states this at the very top of page 61.