宝石安装刀-ec2错误

时间:2014-06-09 09:54:53

标签: amazon-ec2 chef knife

我在centos机器上安装了一个厨师服务器,我还在另一台centos机器上安装了一个工作站。

我也设置了刀。现在我想安装knife-ec2插件。

我正在尝试安装刀插件,但收到以下错误:

[root@ip-server-ip- chef-repo]# /opt/chef/embedded/bin/gem install knife-ec2
Building native extensions.  This could take a while...
Building nokogiri using packaged libraries.
ERROR:  Error installing knife-ec2:
        ERROR: Failed to build gem native extension.

        /opt/chef/embedded/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... *** 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
        --use-system-libraries
        --enable-static
        --disable-static
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --enable-cross-build
        --disable-cross-build
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381: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/1.9.1/mkmf.rb:506:in `try_cpp'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
        from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
        from extconf.rb:103:in `have_iconv?'
        from extconf.rb:148:in `block (2 levels) in iconv_prefix'
        from extconf.rb:90:in `preserving_globals'
        from extconf.rb:143:in `block in iconv_prefix'
        from extconf.rb:116:in `block in each_iconv_idir'
        from extconf.rb:113:in `each'
        from extconf.rb:113:in `each_iconv_idir'
        from extconf.rb:137:in `iconv_prefix'
        from extconf.rb:424:in `block in <main>'
        from extconf.rb:161:in `block in process_recipe'
        from extconf.rb:154:in `tap'
        from extconf.rb:154:in `process_recipe'
        from extconf.rb:419:in `<main>'


Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out

如何解决此错误。

任何领导都非常感谢。

谢谢

2 个答案:

答案 0 :(得分:4)

刀-ec2宝石依赖于一种名为nokogiri的宝石。 nokogiri gem是二进制文件,需要在安装时进行编译。如果向下滚动错误消息,您将看到以下行:

/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

它只是告诉你在工作站上安装gcc和make。在centos中,您可以通过运行:

来完成此操作
$ sudo yum groupinstall development-tools

这将为您提供开始编译gem二进制文件所需的一切。

如果你刚开始和厨师一起开始,我会推荐厨师开发套件Chef-DK。它为您提供了入门所需的所有工具以及用于生成烹饪书的测试工具和帮助程序命令。

祝你好运!

答案 1 :(得分:2)

尝试安装以下软件包。我在安装时遇到了类似的错误。我的问题解决了。它可能会对你有帮助。

sudo apt-get install build-essential  
sudo apt-get install g++ build-essential  
sudo apt-get install rubygems  ruby1.9.1

然后安装刀ec-2插件

$ /opt/chef/embedded/bin/gem install knife-ec2