厨师运行中的NoMethodError错误仅发生在vagrant中

时间:2016-01-29 01:05:33

标签: vagrant chef

我有一本食谱包装了码头工具(以及其他一些食谱)​​。当我尝试在Vagrant中使用此食谱时,NoMethodError获得了coerce_shell_command。这是日志的相关部分:

==> default: Compiling Cookbooks...
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/compat_resource/libraries/autoload.rb:19:in `<top (required)>'
==> default: /opt/chef/embedded/lib/ruby/2.1.0/forwardable.rb:183:in `setup_run_context'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:54:in `load'
==> default: /usr/bin/chef-solo:54:in `<main>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:39:in `<class:DockerBase>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:2:in `<module:DockerCookbook>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:1:in `<top (required)>'
==> default: /opt/chef/embedded/lib/ruby/2.1.0/forwardable.rb:183:in `setup_run_context'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:54:in `load'
==> default: /usr/bin/chef-solo:54:in `<main>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:44:in `<class:DockerBase>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:2:in `<module:DockerCookbook>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:1:in `<top (required)>'
==> default: /opt/chef/embedded/lib/ruby/2.1.0/forwardable.rb:183:in `setup_run_context'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:54:in `load'
==> default: /usr/bin/chef-solo:54:in `<main>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:49:in `<class:DockerBase>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:2:in `<module:DockerCookbook>'
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:1:in `<top (required)>'
==> default: /opt/chef/embedded/lib/ruby/2.1.0/forwardable.rb:183:in `setup_run_context'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:54:in `load'
==> default: /usr/bin/chef-solo:54:in `<main>'
==> default: 
==> default: ================================================================================
==> default: Recipe Compile Error in /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb
==> default: ================================================================================
==> default: 
==> default: NoMethodError
==> default: -------------
==> default: undefined method `coerce_shell_command' for DockerCookbook::DockerBase:Class
==> default: 
==> default: Cookbook Trace:
==> default: ---------------
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:56:in `block in <class:DockerBase>'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:599:in `call'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:599:in `exec_in_resource'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:427:in `coerce'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:91:in `initialize'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:52:in `new'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb:52:in `derive'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb:150:in `property_type'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:54:in `<class:DockerBase>'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:2:in `<module:DockerCookbook>'
==> default:   /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:1:in `<top (required)>'
==> default: 
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef/e6a0063338a4a700e2c49f12beaa529f/cookbooks/docker/libraries/docker_base.rb:
==> default: 
==> default:  49:      NonEmptyArray = property_type(
==> default:  50:        is: [Array, nil],
==> default:  51:        coerce: proc { |v| Array(v).empty? ? nil : Array(v) }
==> default:  52:      ) unless defined?(NonEmptyArray)
==> default:  53:  
==> default:  54:      ShellCommand = property_type(
==> default:  55:        is: [String],
==> default:  56>>       coerce: proc { |v| coerce_shell_command(v) }
==> default:  57:      ) unless defined?(ShellCommand)
==> default:  58:  
==> default:  59:      UnorderedArrayType = property_type(
==> default:  60:        is: [UnorderedArray, nil],
==> default:  61:        coerce: proc { |v| v.nil? ? nil : UnorderedArray.new(Array(v)) }
==> default:  62:      ) unless defined?(UnorderedArrayType)
==> default:  63:  
==> default:  64:      PartialHashType = property_type(
==> default:  65:        is: [PartialHash, nil],
==> default: 
==> default: 
==> default: Running handlers:
==> default: [2016-01-28T16:27:24-08:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2016-01-28T16:27:24-08:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 0 resources updated in 05 seconds
==> default: [2016-01-28T16:27:24-08:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2016-01-28T16:27:24-08:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2016-01-28T16:27:24-08:00] ERROR: undefined method `coerce_shell_command' for DockerCookbook::DockerBase:Class
==> default: [2016-01-28T16:27:24-08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)`

(完全流浪的日志here

我正在使用vagrant-berkshelf安装我的包装菜谱及其所有依赖项。我能够在预期的文件docker/libraries/helpers_base.rb中找到该功能,但是,厨师找不到该功能。

我不认为这是食谱中的错误,因为它在运行时有效:

  • 连接到我们的厨师服务器的服务器
  • ec2上的测试厨房
  • 使用 vagrant 驱动程序的测试厨房

我尝试的事情:

  • 厨师零配置者
  • 厨师独奏供应商
  • 更改synced_folder_type
  • 清除berkshelf的缓存

然而,每次我跑步时,我都会继续得到同样的错误。

1 个答案:

答案 0 :(得分:1)

这是您使用的compat_resource版本中的错误:

==> default: Using compat_resource (12.5.26)

我认为它是用12.7.0修复的。当你再次尝试时,你拉了新的食谱来解决这个问题。

在这里看起来像相关的错误:

https://github.com/chef-cookbooks/docker/issues/621

(看起来它可能没有修复,但它'闻起来'与compat_resources有关,这就是你应该遵循的错误)