【问题标题】:Error executing action `install` on resource 'chef_gem[mysql]' – installing ruby gem through Chef Solo在资源“chef_gem[mysql]”上执行操作“安装”时出错——通过 Chef Solo 安装 ruby​​ gem
【发布时间】:2013-10-22 23:01:19
【问题描述】:

使用 Chef 10.24.0,包括 database cookbook

include_recipe "mysql::server"
include_recipe "database::mysql"

mysql gem 安装失败,输出如下:

[2013-03-10T19:54:29+00:00] INFO: Processing chef_gem[mysql] action install (mysql::ruby line 36)

================================================================================
Error executing action `install` on resource 'chef_gem[mysql]'
================================================================================

NoMethodError
-------------
undefined method `last' for #<Gem::AvailableSet:0x00000002b25be0>

Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb:36:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/database/recipes/mysql.rb:20:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/scafandru/recipes/database.rb:11:in `from_file'

Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb

 36: chef_gem "mysql"

Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb:36:in `from_file'

chef_gem("mysql") do
  provider Chef::Provider::Package::Rubygems
  action :install
  retries 0
  retry_delay 2
  package_name "mysql"
  cookbook_name :mysql
  recipe_name "ruby"
end


================================================================================
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/scafandru/recipes/database.rb
================================================================================

NoMethodError
-------------
chef_gem[mysql] (mysql::ruby line 36) had an error: NoMethodError: undefined method `last' for #<Gem::AvailableSet:0x00000002b25be0>

Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb:36:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/database/recipes/mysql.rb:20:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/scafandru/recipes/database.rb:11:in `from_file'

Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb:

 29:  include_recipe "build-essential"
 30:  include_recipe "mysql::client"
 31:  
 32:  node['mysql']['client']['packages'].each do |mysql_pack|
 33:    resources("package[#{mysql_pack}]").run_action(:install)
 34:  end
 35:  
 36>> chef_gem "mysql"
 37:  

[2013-03-10T19:54:31+00:00] ERROR: Running exception handlers
[2013-03-10T19:54:31+00:00] ERROR: Exception handlers complete
[2013-03-10T19:54:31+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-03-10T19:54:31+00:00] FATAL: NoMethodError: chef_gem[mysql] (mysql::ruby line 36) had an error: NoMethodError: undefined method `last' for #<Gem::AvailableSet:0x00000002b25be0>
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

为了减少所有可能导致安装失败的变量,我放弃了database说明书,并限制在mysql::rubyrecipe中的RubyGem安装

include_recipe "mysql::server"
include_recipe "mysql::ruby"

但错误是等效的。

同样适用于最简单的gem_packageinstall

gem_package 'mysql' do
  options "--no-ri --no-rdoc"
end

我没有想法,有人可以解释一下吗?

【问题讨论】:

    标签: rubygems gem chef-infra chef-solo


    【解决方案1】:

    降级到 RubyGems 的latest pre-2.0 version (1.8.5) 后,一切正常。

    这个问题很可能是addressed in RubyGems 2.0.3

    【讨论】:

    • 这似乎在 v 2.1.9 中再次出现
    猜你喜欢
    • 1970-01-01
    • 2019-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多