使用Chef食谱安装Nokigori时出错

时间:2017-03-31 14:09:20

标签: ruby chef nokogiri chef-recipe

我试图安装和使用Nokigoro进行XML解析(如果有一个替代解析器不会导致无意识的头撞墙 - 我很乐意检查出来)< / p>

我通过厨师客户的食谱运行这个,在我的食谱中我有:

    # include_recipe 'ohai'
chef_gem 'nokogiri'
require 'nokogiri'

这是真的。

将此作为我的运行列表运行会导致以下错误:

    Starting Chef Client, version 12.12.15
[2017-03-31T14:07:36+00:00] WARN: Run List override has been provided.
[2017-03-31T14:07:36+00:00] WARN: Original Run List: []
[2017-03-31T14:07:36+00:00] WARN: Overridden Run List: [recipe[steve-solr]]
resolving cookbooks for run list: ["steve-solr"]
Synchronizing Cookbooks:
  - steve-solr (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: steve-solr::default
  * chef_gem[nokogiri] action install

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

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
    STDOUT: Building native extensions.  This could take a while...
    STDERR: ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

        current directory: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1/ext/nokogiri
    /opt/chef/embedded/bin/ruby -r ./siteconf20170331-19864-1d63c49.rb extconf.rb
    checking if the C compiler accepts ... *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.

    Provided configuration options:
        --with-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/opt/chef/embedded/bin/ruby
        --help
        --clean
    /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
    You have to install development tools first.
        from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `block in try_compile'
        from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:533:in `with_werror'
        from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `try_compile'
        from extconf.rb:138:in `nokogiri_try_compile'
        from extconf.rb:162:in `block in add_cflags'
        from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:630:in `with_cflags'
        from extconf.rb:161:in `add_cflags'
        from extconf.rb:406:in `<main>'

    To see why this extension failed to compile, please check the mkmf.log which can be found here:

      /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/mkmf.log

    extconf failed, exit code 1

    Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1 for inspection.
    Results logged to /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/gem_make.out
    ---- End output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
    Ran /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" returned 1

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/steve-solr/recipes/default.rb:8:in `from_file'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/steve-solr/recipes/default.rb

      8: chef_gem 'nokogiri'
      9: require 'nokogiri'

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/steve-solr/recipes/default.rb:8:in `from_file'

    chef_gem("nokogiri") do
      package_name "nokogiri"
      action [:install]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :chef_gem
      cookbook_name "steve-solr"
      recipe_name "default"
      gem_binary "/opt/chef/embedded/bin/gem"
    end

    Platform:
    ---------
    x86_64-linux


  ================================================================================
  Recipe Compile Error in /var/chef/cache/cookbooks/steve-solr/recipes/default.rb
  ================================================================================

  Mixlib::ShellOut::ShellCommandFailed
  ------------------------------------
  chef_gem[nokogiri] (steve-solr::default line 8) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
  ---- Begin output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
  STDOUT: Building native extensions.  This could take a while...
  STDERR: ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

      current directory: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1/ext/nokogiri
  /opt/chef/embedded/bin/ruby -r ./siteconf20170331-19864-1d63c49.rb extconf.rb
  checking if the C compiler accepts ... *** extconf.rb failed ***
  Could not create Makefile due to some reason, probably lack of necessary
  libraries and/or headers.  Check the mkmf.log file for more details.  You may
  need configuration options.

  Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/chef/embedded/bin/ruby
    --help
    --clean
  /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
  You have to install development tools first.
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `block in try_compile'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:533:in `with_werror'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `try_compile'
    from extconf.rb:138:in `nokogiri_try_compile'
    from extconf.rb:162:in `block in add_cflags'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:630:in `with_cflags'
    from extconf.rb:161:in `add_cflags'
    from extconf.rb:406:in `<main>'

  To see why this extension failed to compile, please check the mkmf.log which can be found here:

    /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/mkmf.log

  extconf failed, exit code 1

  Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1 for inspection.
  Results logged to /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/gem_make.out
  ---- End output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
  Ran /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" returned 1

  Cookbook Trace:
  ---------------
    /var/chef/cache/cookbooks/steve-solr/recipes/default.rb:8:in `from_file'

  Relevant File Content:
  ----------------------
  /var/chef/cache/cookbooks/steve-solr/recipes/default.rb:

    1:  #
    2:  # Cookbook Name:: steve-solr
    3:  # Recipe:: default
    4:  #
    5:  # Copyright (c) 2017 The Authors, All Rights Reserved.
    6:  # include_recipe 'aws'
    7:  # include_recipe 'ohai'
    8>> chef_gem 'nokogiri'
    9:  require 'nokogiri'
   10:
   11:  class SolrObject
   12:      attr_reader :coreName
   13:      def initialize(name)
   14:          @coreName = name
   15:      end
   16:
   17:      def coreName

  Platform:
  ---------
  x86_64-linux


  Running handlers:
[2017-03-31T14:07:38+00:00] ERROR: Running exception handlers
  Running handlers complete
[2017-03-31T14:07:38+00:00] ERROR: Exception handlers complete
  Chef Client failed. 0 resources updated in 02 seconds
[2017-03-31T14:07:38+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2017-03-31T14:07:38+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-03-31T14:07:38+00:00] ERROR: chef_gem[nokogiri] (steve-solr::default line 8) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
STDOUT: Building native extensions.  This could take a while...
STDERR: ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    current directory: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1/ext/nokogiri
/opt/chef/embedded/bin/ruby -r ./siteconf20170331-19864-1d63c49.rb extconf.rb
checking if the C compiler accepts ... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/chef/embedded/bin/ruby
    --help
    --clean
/opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `block in try_compile'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:533:in `with_werror'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `try_compile'
    from extconf.rb:138:in `nokogiri_try_compile'
    from extconf.rb:162:in `block in add_cflags'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:630:in `with_cflags'
    from extconf.rb:161:in `add_cflags'
    from extconf.rb:406:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/gem_make.out
---- End output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
Ran /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" returned 1
[2017-03-31T14:07:38+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

这个在我的错误文件中:

"gcc -o conftest -I/opt/chef/embedded/include/ruby-2.1.0/x86_64-linux -I/opt/chef/embedded/include/ruby-2.1.0/$
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

任何有关修复的帮助或建议都会非常棒,谢谢。

1 个答案:

答案 0 :(得分:1)

完全删除chef_gem。我们将nokogiri与Chef安装程序捆绑在一起,因此您不必安装或编译它,除非您出于某种原因特别需要最新版本。