Nokogiri gem安装在Capistrano部署失败

时间:2015-07-04 15:53:31

标签: ruby-on-rails ruby capistrano nokogiri bundler

当尝试通过bundler / capistrano安装Nokogiri时,我收到错误:

An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue

深入挖掘我可以看到>> 需要libxml2版本2.6.21或更高版本!

错误消息还显示Make sure that gem install nokogiri -v '1.6.5' succeeds before bundling.

好吧,你可以看到这不是问题:

vagrant@vagrant:~$ gem install nokogiri -v '1.6.5'
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.5
1 gem installed

可悲的是,即使通过此测试,上限部署仍会失败并出现相同的错误。

An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue

我确保在我的虚拟机上安装了最新版本的libxml2。我甚至删除了我的项目目录,并重新启动了服务器:

$ vagrant ssh
$ sudo apt-get update
$ sudo apt-get upgrade libxml2
$ sudo rm -rf /var/www/rails-devise-capistrano/
$ sudo reboot

我也尝试将此添加到deploy.rb

set :bundle_env_variables, { nokogiri_use_system_libraries: 1 }

以下是捆绑错误

/home/vagrant/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20150704-1327-1yf3b95.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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
        --without-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=/home/vagrant/.rbenv/versions/2.2.2/bin/$(RUBY_BASE_NAME)
        --help
        --clean
        --use-system-libraries=true
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --with-xml2-dir
        --without-xml2-dir
        --with-xml2-include
        --without-xml2-include=${xml2-dir}/include
        --with-xml2-lib
        --without-xml2-lib=${xml2-dir}/lib
        --with-libxml-2.0-config
        --without-libxml-2.0-config
        --with-pkg-config
        --without-pkg-config
        --with-xslt-dir
        --without-xslt-dir
        --with-xslt-include
        --without-xslt-include=${xslt-dir}/include
        --with-xslt-lib
        --without-xslt-lib=${xslt-dir}/lib
        --with-libxslt-config
        --without-libxslt-config
        --with-pkg-config
        --without-pkg-config
        --with-exslt-dir
        --without-exslt-dir
        --with-exslt-include
        --without-exslt-include=${exslt-dir}/include
        --with-exslt-lib
        --without-exslt-lib=${exslt-dir}/lib
        --with-libexslt-config
        --without-libexslt-config
        --with-pkg-config
        --without-pkg-config

extconf failed, exit code 1

2 个答案:

答案 0 :(得分:2)

我遇到了同样的问题并尝试了很多选项,但我需要的是这两个库:

libxml2-devel
libxslt-devel

事情是输出总是提到libxml2,但所需的东西似乎在开发库中。 (我并没有真正进入图书馆和其他东西,所以我无法准确地说出问题是什么。)我使用的是Cent OS,因此可能与你的设置有点不同(类似于libxml2-dev libxslt1-dev)。

答案 1 :(得分:1)

在安装gem之前安装 zlib1g-dev 应该解决它。 对于CentOS:

yum install zlib-devel

在版本1.6.6.1中,开发人员在构建zlib之前已恢复检查libxml2是否可用。

这为我解决了这个问题:

gem 'nokogiri', '1.6.7.rc2'