【问题标题】:Nokogiri gem install failing in Capistrano deployCapistrano 部署中的 Nokogiri gem 安装失败
【发布时间】:2015-09-22 05:21:41
【问题描述】:

当尝试通过 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

遗憾的是,即使通过了此测试,cap deploy 仍然会失败并出现相同的错误。

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

我已经确保我的 virtualbox 上安装了最新版本的 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

【问题讨论】:

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


    【解决方案1】:

    在安装 gem 之前安装 zlib1g-dev 应该可以解决这个问题。 对于 CentOS:

    yum install zlib-devel
    

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

    这为我解决了这个问题:

    gem 'nokogiri', '1.6.7.rc2'
    

    【讨论】:

    • 这没有提供问题的答案。要批评或要求作者澄清,请在他们的帖子下方发表评论 - 您可以随时评论自己的帖子,一旦您有足够的reputation,您就可以comment on any post
    • @Drenmi 这怎么不能提供答案?它提出了一个合理的解决方案。如果您认为这是不正确的,您应该投反对票并发表评论来解释您的担忧。我们不应该试图从评论中删除“错误”的答案。
    • @Undo:重新思考之后,我稍微倾向于你的立场,但还是很矛盾。只是告诉人们使用另一个版本可能会治标不治本,但不能解决问题的实际原因。
    • 谢谢,我编辑了我的答案。希望对作者有所帮助。
    【解决方案2】:

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

    libxml2-devel
    libxslt-devel
    

    问题是输出总是提到libxml2,但所需的东西似乎在开发库中。 (我不是很喜欢图书馆和其他东西,所以我不能确切地说出问题是什么。)我使用 Cent OS,所以它可能与您的设置有点不同(类似于libxml2-dev libxslt1-dev)。

    【讨论】:

    • 我遇到了同样的问题。必须使用sudo yum install libxml2-devel libxstl-devel
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多