Shinedog
Shinedog

Reputation: 1

Learning Chef - Unable to Run Cookbook - Wrong Number of Arguments (1 for 0)

I've been following the tutorial at:

Building Your Chef Workstation on Windows

GitHub Repo of local

And it has been extremely helpful.

I've had to make a number of changes to get my code to the point where I should be able to execute the final instruction:

chef-client --local-mode --override-runlist 'local'

Changes:

winbox version - 0.1.68 (tutorial asks for 0.1.50) and branch from repository - master (tutorial asks for smurawski/updates)

And I've been able to get everything working up to the final instruction.

Now I'm getting an error:

PS C:\workstation-repo> chef-client --local-mode --override-runlist 'local'
[2016-05-18T19:31:22+10:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.9.41
[2016-05-18T19:31:32+10:00] WARN: Run List override has been provided.
[2016-05-18T19:31:32+10:00] WARN: Original Run List: []
[2016-05-18T19:31:32+10:00] WARN: Overridden Run List: [recipe[local]]
resolving cookbooks for run list: ["local"]
Synchronizing Cookbooks:
  - local (0.1.0)
  - winbox (0.1.68)
  - git (4.5.0)
  - windows (1.41.0)
  - build-essential (4.0.0)
  - dmg (2.4.0)
  - yum-epel (0.7.0)
  - chef_handler (1.4.0)
  - seven_zip (2.0.0)
  - mingw (1.0.0)
  - yum (3.10.0)
  - compat_resource (12.9.1)
Installing Cookbook Gems:
Compiling Cookbooks...
C:/opscode/chefdk/embedded/lib/ruby/2.1.0/i386-mingw32/dl.so: warning: already initialized constant DL::RUBY_FREE
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.1.1/lib/net/ssh/authentication/pageant.rb:16: warning: previous definiti
on of RUBY_FREE was here
DL is deprecated, please use Fiddle

================================================================================
Recipe Compile Error in C:/Users/nicho/.chef/local-mode-cache/cache/cookbooks/local/recipes/default.rb
================================================================================

ArgumentError
-------------
wrong number of arguments (1 for 0)

Platform:
---------
i386-mingw32


Running handlers:
[2016-05-18T19:31:35+10:00] ERROR: Running exception handlers
Running handlers complete
[2016-05-18T19:31:35+10:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 13 seconds
[2016-05-18T19:31:35+10:00] FATAL: Stacktrace dumped to C:/Users/nicho/.chef/local-mode-cache/cache/chef-stacktrace.out
[2016-05-18T19:31:35+10:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-05-18T19:31:35+10:00] FATAL: ArgumentError: wrong number of arguments (1 for 0)

I'm unable to identify the source of the error in default.rb

#
# Cookbook Name:: local
# Recipe:: default
#
# Copyright (c) 2016 Nicholas Adriaanse, All Rights Reserved.
include_recipe 'git'
include_recipe 'local::repositories'
include_recipe 'local::links'
include recipe 'winbox::chocolatey_install'
include_recipe 'winbox::powershell_dev'
include_recipe 'winbox::readline'
include_recipe 'winbox::editor'
include_recipe 'winbox::console'
include_recipe 'winbox::git'
include_recipe 'local::packages'

#gems to install
default['local']['gems'] = %w[kitchen-pester kitchen-hyperv kitchen-dsc pry]

Stacktrace:

Generated at 2016-05-18 19:31:35 +1000
ArgumentError: wrong number of arguments (1 for 0)
C:/Users/nicho/.chef/local-mode-cache/cache/cookbooks/local/recipes/default.rb:9:in `from_file'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/mixin/from_file.rb:30:in `instance_eval'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/mixin/from_file.rb:30:in `from_file'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/cookbook_version.rb:233:in `load_recipe'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/run_context.rb:354:in `load_recipe'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/run_context/cookbook_compiler.rb:140:in `block in compile_recipes'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/run_context.rb:176:in `load'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/policy_builder/expand_node_object.rb:97:in `setup_run_context'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/client.rb:508:in `setup_run_context'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/client.rb:278:in `run'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application.rb:267:in `run_with_graceful_exit_option'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application.rb:243:in `block in run_chef_client'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/local_mode.rb:44:in `with_server_connectivity'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application.rb:226:in `run_chef_client'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/client.rb:456:in `sleep_then_run_chef_client'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/client.rb:443:in `block in interval_run_chef_client'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/client.rb:442:in `loop'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/client.rb:442:in `interval_run_chef_client'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/client.rb:426:in `run_application'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application.rb:58:in `run'
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/bin/chef-client:26:in `<top (required)>'
C:/opscode/chefdk/bin/chef-client:61:in `load'
C:/opscode/chefdk/bin/chef-client:61:in `<main>'

Upvotes: 0

Views: 588

Answers (1)

Martin
Martin

Reputation: 2825

Normally, this statement would be in an attributes file, not a recipe file: default['local']['gems'] = %w(kitchen-pester kitchen-hyperv kitchen-dsc pry)

If you're going to do it in a recipe, it needs to be: node.default['local']['gems'] = %w(kitchen-pester kitchen-hyperv kitchen-dsc pry)

However, I would strongly encourage you to move it to an attributes/*.rb file.

Upvotes: 1

Related Questions