当前位置: 首页>>技术教程>>正文


使用Rails 3.1.0和Ubuntu安装Nokogiri 1.5.0时出错

, , ,

问题描述

这是在服务器上运行捆绑安装供应商/ gems 的错误:

Installing nokogiri (1.5.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/dtt/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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/dtt/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
        --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-iconv-dir
        --without-iconv-dir
        --with-iconv-include
        --without-iconv-include=${iconv-dir}/include
        --with-iconv-lib
        --without-iconv-lib=${iconv-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-xslt-dir
        --without-xslt-dir
        --with-xslt-include
        --without-xslt-include=${xslt-dir}/include
        --with-xslt-lib
        --without-xslt-lib=${xslt-dir}/lib


Gem files will remain installed in /vol/www/emclab/releases/20111104001151/vendor/gems/ruby/1.9.1/gems/nokogiri-1.5.0 for inspection.
Results logged to /vol/www/emclab/releases/20111104001151/vendor/gems/ruby/1.9.1/gems/nokogiri-1.5.0/ext/nokogiri/gem_make.out
An error occured while installing nokogiri (1.5.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.0'` succeeds before bundling.

您可以跳过此部分。该错误消息几乎可以自我解释,但是该网站还需要一些其他单词来解释该代码。

有什么想法吗?

最佳方法

您需要在计算机上安装所有必需的库。当您安装RVM时,它应该已经为您列出了。在当前版本的rvm上,可以运行rvm requirements以查看确切的列表。现在,该列表是:

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

次佳方法

您缺少某些软件包。尝试运行此命令(仅限Linux):

$ sudo apt-get install libxslt-dev libxml2-dev

第三种方法

看起来像是gem依赖错误。

您需要运行bundle update命令。它将解决依赖关系:

bundle update

第四种方法

您需要安装libxml2。

在Mac OS上,使用自制软件将是:

brew install libxml2

参见http://nokogiri.org/tutorials/installing_nokogiri.html

第五种方法

只是这样做:

sudo apt-get install libxslt-dev libxml2-dev libxml2

然后在终端(linux)/cmd(windows)中输入以下内容:

export NOKOGIRI_USE_SYSTEM_LIBRARIES=true

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/9906.html,未经允许,请勿转载。