Chef,在 Centos 6.5 上安装带有系统库的 nokogiri 失败

Chef,在 Centos 6.5 上安装带有系统库的 nokogiri 失败

我正在尝试修复一个需要 Centos 6.5 上的宝石 nokogiri 和 savon 的配方。

由于简单

chef_gem 'nokogiri'
require 'nokogiri'
chef_gem 'savon'
require 'savon'

不起作用(chef 说修补 libxml2 2.8.0 返回了一个错误),(编辑:这是完整的错误http://pastebin.com/mUZVyZ4H

我决定尝试使用系统库安装 nokogiri。

如果我直接在服务器上执行此操作,一切都正常:

[vagrant@localhost ~]$ sudo /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.6.2.1" -- --use-system-libraries
Building native extensions.  This could take a while...
Building nokogiri using system libraries.
Successfully installed mini_portile-0.6.0
Successfully installed nokogiri-1.6.2.1
2 gems installed

但是如果我使用以下命令通过 Chef 运行安装:

chef_gem "nokogiri" do
  options("-- --use-system-libraries")
  action :install
end
require 'nokogiri'

我收到一个错误:

------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of gem install nokogiri -q --no-rdoc --no-ri -v "1.6.2.1" -- --use-system-libraries ----
STDOUT: 
STDERR: ERROR:  Error installing nokogiri:
    nokogiri requires Ruby version >= 1.9.2.
---- End output of gem install nokogiri -q --no-rdoc --no-ri -v "1.6.2.1" -- --use-system-libraries ----
Ran gem install nokogiri -q --no-rdoc --no-ri -v "1.6.2.1" -- --use-system-libraries returned 1

由于嵌入式 Ruby 是 1.9.3

[vagrant@localhost ~]$ /opt/chef/embedded/bin/ruby --version
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

我的猜测是 Chef 使用了错误的 gem 二进制文件(系统 Ruby 是 1.8.7),但我不知道为什么会发生这种情况,特别是因为之前chef_gem 'nokogiri'似乎使用正确的二进制文件。

我是否遗漏了什么?

相关内容