# NoMethodError, what does this mean?

**URL:** <https://discourse.chef.io/t/nomethoderror-what-does-this-mean/15093>\
**Category:** Chef Infra (archive)\
**Created:** [May 9, 2019, 5:38pm UTC](https://discourse.chef.io/t/nomethoderror-what-does-this-mean/15093 "2019-05-09T17:38:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![servi](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@servi](https://discourse.chef.io/u/servi)\
**Post date:** [May 9, 2019, 5:38pm UTC](https://discourse.chef.io/t/nomethoderror-what-does-this-mean/15093/1 "2019-05-09T17:38:22Z")

</div>

Hello,

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.

```auto
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]'
    ================================================================================

    NoMethodError
    -------------
    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 []
    end

    System Info:
    ------------
    chef_version=14.10.9
    platform=ubuntu
    platform_version=18.04
    ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
    program_name=/usr/bin/chef-apply
    executable=/opt/chefdk/bin/chef-apply

[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'  
variables(  
:post\_size =\> '12M',  
:upload\_size =\> '10M'  
)  
end

---

<div class="post-metadata">

**Author:** ![cheeseplus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/cheeseplus/32/960_2.png) [@cheeseplus](https://discourse.chef.io/u/cheeseplus)\
**Post date:** [May 10, 2019, 6:06pm UTC](https://discourse.chef.io/t/nomethoderror-what-does-this-mean/15093/2 "2019-05-10T18:06:53Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![servi](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@servi](https://discourse.chef.io/u/servi)\
**Post date:** [May 13, 2019, 2:03pm UTC](https://discourse.chef.io/t/nomethoderror-what-does-this-mean/15093/3 "2019-05-13T14:03:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alexpatt](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@alexpatt](https://discourse.chef.io/u/alexpatt)\
**Post date:** [May 13, 2019, 7:07pm UTC](https://discourse.chef.io/t/nomethoderror-what-does-this-mean/15093/4 "2019-05-13T19:07:52Z")

</div>

I've found this book online:  
[https://books.google.ca/books?id=fT1PAQAAQBAJ&pg=PA56&lpg=PA56&dq="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](https://books.google.ca/books?id=fT1PAQAAQBAJ&pg=PA56&lpg=PA56&dq=%22undefined+method+%27preferred_filename_on_disk_location%27+for+nil:NilClass%22&source=bl&ots=QXm5PfL8Gy&sig=ACfU3U1z-pUUMJyJIIbuq9Lm5Nri0-9Tnw&hl=en&sa=X&ved=2ahUKEwjB96uTjZniAhUineAKHRaKCSkQ6AEwB3oECAkQAQ#v=onepage&q=%22undefined%20method%20'preferred_filename_on_disk_location'%20for%20nil%3ANilClass%22&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.

---

<div class="post-metadata">

**Author:** ![alexpatt](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@alexpatt](https://discourse.chef.io/u/alexpatt)\
**Post date:** [May 13, 2019, 7:12pm UTC](https://discourse.chef.io/t/nomethoderror-what-does-this-mean/15093/5 "2019-05-13T19:12:17Z")

</div>

It states this at the very top of page 61.
