I am newbie in ruby and chef. I was trying to create a file through template resource. After running chef-apply command , I am getting some error "NoMethodError :undefined method `preferred_filename_on_disk_location' for nil:NilClass " . I tried to google it, but no correct solution found.
Please help.
chef-apply abc.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe) * template[file.txt] action create
================================================================================
Error executing action `create` on resource 'template[file.txt]'
================================================================================
NoMethodError
-------------
undefined method `preferred_filename_on_disk_location' for nil:NilClass
Resource Declaration:
---------------------
# In abc.rb
10: template "file.txt" do
11: source "file.erb"
12: mode "0666"
13: end
14:
Compiled Resource:
# Declared in abc.rb:10:in `run_chef_recipe'
template("file.txt") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
source "file.erb"
declared_type :template
cookbook_name "(chef-apply cookbook)"
recipe_name "(chef-apply recipe)"
mode "0666"
path "file.txt"
end
Platform:
---------
x86_64-linux
[2017-01-02T18:37:07-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out [2017-01-02T18:37:07-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report [2017-01-02T18:37:07-05:00] FATAL: NoMethodError: template[file.txt] ((chef-apply cookbook)::(chef-apply recipe) line 10) had an error: NoMethodError: undefined method `preferred_filename_on_disk_location' for nil:NilClass