【问题标题】:An error occurred while installing nokogiri (1.5.2)安装 nokogiri (1.5.2) 时出错
【发布时间】:2012-04-01 07:29:31
【问题描述】:

当我尝试运行 ruby​​ on rails 项目时出现错误:

An error occurred while installing nokogiri (1.5.2), and bundle cannot continue.
Make sure that 'gem install nokogiri -v 1.5.2 succeed before building.

我正在开发 Ubuntu 10.10

我的同事在 Windows/RVM 上使用,没有这个问题。

编辑:

gem_make.out

/opt/bitnami/ruby/bin/ruby extconf.rb
extconf.rb:10: Use RbConfig instead of obsolete and deprecated Config.
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv 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=/opt/bitnami/ruby/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
    --with-iconvlib
    --without-iconvlib

【问题讨论】:

  • 运行gem install nokogiri,然后将错误消息(全部)发布到问题中
  • 感谢您的快速回答。这里的消息是:Gem 文件仍将安装在 /opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.2 中以供检查。结果记录到 /opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.2/ext/nokogiri/gem_make.out
  • 应该不止这些。您发布的是从失败中恢复的内容。并且在您发布数据时继续编辑您的原始问题......评论框太多了
  • 你刚刚看到了完整的错误页面。我对我的第一条评论进行了编辑
  • 看起来 Skydreamer 击败了我 :)

标签: ruby-on-rails nokogiri ubuntu-10.10


【解决方案1】:

从输出:

libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

安装 libiconv。

【讨论】:

    【解决方案2】:

    nokogiri 要求

    sudo apt-get install libxslt-dev libxml2-dev

    sudo gem install nokogiri

    您可以访问http://nokogiri.org/tutorials/installing_nokogiri.html

    【讨论】:

    • 我已经安装了 libxslt-dev libxml2-dev,只是缺少 nokogiri gem。原来我的问题与 .bundle 文件夹有关。我把它作为 root 而不是我的用户和组。
    【解决方案3】:

    不需要安装任何附加包。您可以将包含的库与 BitNami 一起使用(在 /opt/bitnami/common 中)。您只需要加载 BitNami 环境并指定 libxml2 文件的路径。在对此进行测试时,我遇到了类似的问题,但使用 libxml2,可以为您收到的 iconv 错误应用类似的解决方案。

    $/opt/bitnami/rubyconsole
    
    $sudo gem install nokogiri  -- --with-xml2-dir=/opt/bitnami/common --with-xml2-include=/opt/bitnami/common/include/libxml2
    
    Building native extensions.  This could take a while...
    Successfully installed nokogiri-1.5.2
    1 gem installed
    Installing ri documentation for nokogiri-1.5.2...
    Installing RDoc documentation for nokogiri-1.5.2...
    

    安装系统包并使用它们的解决方案应该也可以。

    【讨论】:

    • 我尝试了您上面列出的代码,但仍然得到libxml2 is missing。我正在使用 bitnami 堆栈,请问您还有什么建议吗?
    • 您是否尝试了确切的命令?注意 nokogiri 和 --withxxxx 之后的 --
    • 这个答案应该优先于其他答案,因为它提倡使用现有的库。
    【解决方案4】:

    什么对我有用(Mac OS X):

    $ xcode-select --install
    

    【讨论】:

    • 作为 Mac 用户,这对我很有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    • 2015-05-15
    • 2015-03-01
    • 1970-01-01
    相关资源
    最近更新 更多