Skip to content

Instantly share code, notes, and snippets.

@sdadh01
Created July 15, 2014 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdadh01/33543b6ccf24ed848669 to your computer and use it in GitHub Desktop.
Save sdadh01/33543b6ccf24ed848669 to your computer and use it in GitHub Desktop.
chef windows_batch NoMethodErrror
chef version: 11.12.8-2 on windows
-----------------------------------
I get a NoMethodError saying windows_batch does not exist even though "depends 'windows'" is in my metadata.rb (see below). Only using windows_batch because the windows_zipfile came up with the same error. Weirdly windows_package works fine.
chef-client output
------------------
PS C:\Users\Administrator> chef-client
Starting Chef Client, version 11.12.8
resolving cookbooks for run list: ["jobaline_www"]
Synchronizing Cookbooks:
- jobaline_www
- artifact
- windows
- chef_handler
- iis
Compiling Cookbooks...
Recipe: windows::default
* chef_gem[win32-api] action install (up to date)
* chef_gem[win32-service] action install (up to date)
* chef_gem[windows-api] action install (up to date)
* chef_gem[windows-pr] action install (up to date)
* chef_gem[win32-dir] action install (up to date)
* chef_gem[win32-event] action install (up to date)
* chef_gem[win32-mutex] action install (up to date)
================================================================================
Recipe Compile Error in C:/chef/cache/cookbooks/jobaline_www/recipes/default.rb
================================================================================
NoMethodError
-------------
No resource or method named `windows_batch' for `Chef::Recipe "deploy"'
Cookbook Trace:
---------------
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/dsl/recipe.rb:47:in `rescue in met
hod_missing'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/dsl/recipe.rb:44:in `method_missin
g'
C:/chef/cache/cookbooks/jobaline_www/recipes/deploy.rb:57:in `from_file'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/mixin/from_file.rb:30:in `instance
_eval'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/mixin/from_file.rb:30:in `from_fil
e'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/cookbook_version.rb:237:in `load_r
ecipe'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context.rb:165:in `load_recipe
'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context.rb:134:in `block in in
clude_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context.rb:133:in `each'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context.rb:133:in `include_rec
ipe'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/dsl/include_recipe.rb:26:in `inclu
de_recipe'
C:/chef/cache/cookbooks/jobaline_www/recipes/default.rb:11:in `from_file'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/mixin/from_file.rb:30:in `instance
_eval'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/mixin/from_file.rb:30:in `from_fil
e'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/cookbook_version.rb:237:in `load_r
ecipe'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context.rb:165:in `load_recipe
'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:1
40:in `block in compile_recipes'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:1
38:in `each'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:1
38:in `compile_recipes'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context/cookbook_compiler.rb:7
5:in `compile'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/run_context.rb:88:in `load'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/policy_builder/expand_node_object.
rb:73:in `setup_run_context'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/client.rb:265:in `setup_run_contex
t'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/client.rb:429:in `do_run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/client.rb:227:in `run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/application.rb:217:in `run_chef_cl
ient'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/application/client.rb:328:in `bloc
k in run_application'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/application/client.rb:317:in `loop
'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/application/client.rb:317:in `run_
application'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/application.rb:67:in `run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/bin/chef-client:26:in `<top (required)>'
C:/opscode/chef/bin/chef-client:23:in `load'
C:/opscode/chef/bin/chef-client:23:in `<main>'
Relevant File Content:
----------------------
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8-x86-mingw32/lib/chef/dsl/recipe.rb:
40: elsif have_resource_class_for?(method_symbol)
41: # Otherwise, we're rocking the regular resource call route.
42: declare_resource(method_symbol, args[0], caller[0], &block)
43: else
44: begin
45: super
46: rescue NoMethodError
47>> raise NoMethodError, "No resource or method named `#{method_symbol}' for #{describe_self_for_error}"
48: rescue NameError
49: raise NameError, "No resource, method, or local variable named `#{method_symbol}' for #{describe_self_
for_error}"
50: end
51: end
52: end
53:
54: def has_resource_definition?(name)
55: yes_or_no = run_context.definitions.has_key?(name)
56:
Running handlers:
[2014-07-15T17:27:52+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-07-15T17:27:52+00:00] ERROR: Exception handlers complete
[2014-07-15T17:27:52+00:00] FATAL: Stacktrace dumped to C:/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 14.966784 seconds
[2014-07-15T17:27:52+00:00] FATAL: NoMethodError: No resource or method named `windows_batch' for `Chef::Recipe "deploy"
'
metadata.rb
-----------
version '0.1.31'
depends "artifact"
depends "iis"
depends "windows"
deploy recipe fragment
----------------------
windows_package '7-Zip 9.20 (x64 edition)' do
source "#{download_dir}/7z920-x64.msi"
action :install
end
# unzip into release directory
windows_batch "unzip #{download_dir}/#{release_zip} to #{release_dir}" do
code <<-EOF
C:\Program Files\7-zip\7z.exe' x -o#{release_dir} #{download_dir}/#{release_zip}
EOF
end
@sdadh01
Copy link
Author

sdadh01 commented Jul 15, 2014

include_recipe "windows" is in the cookbook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment