首页 文章

nokogiri宝石安装错误

提问于
浏览
57

我知道有很多关于这个宝石的问题,但没有答案对我有用 .

当我在SSH gem install nokogiri 中运行时出现此错误:

Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.8.0... OK
Running patch with /home/user58952277/.gem/ruby/1.9.3/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0001-Fix-parser-local-buffers-size-problems.patch...
Running 'patch' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.8.0/patch.log' to see what happened.
*** 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.

我的主人告诉我所有lib都已安装 . 以下是执行install nokogiri命令后的完整日志:

Building native extensions.  This could take a while...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

        /opt/rubies/ruby-1.9.3/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... yes
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.8.0... OK
Running patch with /home/user58952277/.gem/ruby/1.9.3/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0001-Fix-parser-local-buffers-size-problems.patch...
Running 'patch' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.8.0/patch.log' to see what happened.
*** 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/rubies/ruby-1.9.3/bin/ruby
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build
/home/user58952277/.gem/ruby/1.9.3/gems/mini_portile-0.6.0/lib/mini_portile.rb:279:in `block in execute': Failed to complete patch task (RuntimeError)
    from /home/user58952277/.gem/ruby/1.9.3/gems/mini_portile-0.6.0/lib/mini_portile.rb:271:in `chdir'
    from /home/user58952277/.gem/ruby/1.9.3/gems/mini_portile-0.6.0/lib/mini_portile.rb:271:in `execute'
    from extconf.rb:282:in `block in patch'
    from extconf.rb:279:in `each'
    from extconf.rb:279:in `patch'
    from /home/user58952277/.gem/ruby/1.9.3/gems/mini_portile-0.6.0/lib/mini_portile.rb:108:in `cook'
    from extconf.rb:253:in `block in process_recipe'
    from extconf.rb:154:in `tap'
    from extconf.rb:154:in `process_recipe'
    from extconf.rb:419:in `<main>'

14 回答

  • 2

    这适用于Windows 7 Home Basic 64位:

    gem install nokogiri -v 1.6.2.1 -- --use-system-libraries
    
  • 45

    OS X Yosemite对我有用 .

    gem install nokogiri -v 1.6.5 -- --use-system-libraries
    
  • 3

    由于未列出的构建依赖性,我遇到了同样的问题 . 当我找到有问题的tmp目录时:

    find ~/.rbenv/ -name patch.log
    

    它说:

    sh:patch:找不到命令

    修复了一个简单的问题:

    sudo yum install -y patch
    
  • 1

    在OSX优胜美地,我在一个终端做了 xcode-select --install . 之后, bundle 与该宝石一起工作正常 .

  • 2

    macOS High Sierra 10.13

    gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2/
    

    macOS Sierra 10.12:

    gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2/
    

    OS X El Capitan 10.11

    gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/
    

    如果您没有权限,请考虑添加 sudo .


    出于某种原因,Apple的Yosemite OSX版本没有libxml2的系统可访问安装 . Nokogiri需要这个才能编译,幸运的是Xcode有一个与之捆绑的libxml2版本 - 我们只需要在安装gem时指定它 . 让Nokogiri正确安装非常重要,因为到目前为止,Rails 4.2.1.rc4会自动尝试安装它,你会感到很痛苦 .

    Checkout this post for more info .

  • 2

    最后,这个问题是由nokogiri本身造成的,因为它与某些系统不相容_1359762 .
    所以要安装nokogiri,我必须告诉它它应该使用系统库 .

    我手动安装它:

    gem install nokogiri -v 1.6.2.1 -- --use-system-libraries
    

    它运作良好 . 其他答案没有解决它 .

  • 126

    这对OS X 10.10.3优胜美地有用:

    sudo gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --with-xml2-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib
    
  • 0

    就像wongzigii所说,install命令与macOS Sierra的那些标志一起使用

    gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2/

  • 4

    当前答案中没有任何内容适用于我(我使用的是Ubuntu 16.04,而不是Mac) .

    但是,通过遵循Nokogiri site中的说明,这部分就可以了:

    # See http://www.nokogiri.org/tutorials/installing_nokogiri.html#ubuntu___debian
    sudo apt-get install build-essential patch
    sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
    

    注意我自2009年以来一直在使用Nokogiri,我一直都无法安装它 . 任何进一步的评论可能都不符合SO T&C :)

  • 18

    在Mac OS El Capitan中安装Nokogiri:

    brew install libxml2 bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"

    bundle install

    它为我工作:)

  • -1

    在我运行之前,Nokogiri没有在我的OSX Sierra机器上找到Xcode库:

    sudo xcodebuild -license accept

  • 24

    这对我有用:

    sudo gem install nokogiri -v 'versionNumber'  -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --with-xml2-lib=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib
    
  • 2

    经过多次努力,以下工作对我有用(OS X 10.8.5,macports) . (我正在安装github页面,即jekyll)

    /opt/local/bin/gem install nokogiri -v 1.6.6.2 -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/libxml2 --with-xml2-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib
    
  • 2

    我正在使用macOS Sierra .

    去了nokogiri文档并遵循这个:

    在MAC OSX上

    使用Nokogiri的libxml2和libxslt安装应该Just Work™ .

    首先,确保您拥有最新版本的RubyGems和xcode命令行工具:

    1 gem update --system

    2 xcode-select --install

    然后安装nokogiri:

    1 gem install nokogiri

相关问题