简体   繁体   English

无法安装nokogiri宝石

[英]Can't install nokogiri gem

I'm installing nokogiri 1.6.6.2 on Arch Linux,as metasploit installation can't proceed without it. 我正在Arch Linux上安装nokogiri 1.6.6.2,因为如果没有它,metasploit安装就无法继续。 I got the following output: 我得到以下输出:

[ blackarch Downloads ]# gem install ./nokogiri-1.6.6.2.gem                       
Building native extensions.  This could take a while...
ERROR:  Error installing ./nokogiri-1.6.6.2.gem:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby -r ./siteconf20151103-1360-1u3d2zo.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
    - 0001-Revert-Missing-initialization-for-the-catalog-module.patch
    - 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

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

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

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.2... OK
Running patch with /root/.gem/ruby/2.2.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... ERROR, review '/root/.gem/ruby/2.2.0/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.2/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=/usr/bin/$(RUBY_BASE_NAME)
    --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
/root/.gem/ruby/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:279:in `block in execute': Failed to complete patch task (RuntimeError)
    from /root/.gem/ruby/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `chdir'
    from /root/.gem/ruby/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `execute'
    from extconf.rb:311:in `block in patch'
    from extconf.rb:308:in `each'
    from extconf.rb:308:in `patch'
    from /root/.gem/ruby/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:108:in `cook'
    from extconf.rb:278:in `block in process_recipe'
    from extconf.rb:177:in `tap'
    from extconf.rb:177:in `process_recipe'
    from extconf.rb:475:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /root/.gem/ruby/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /root/.gem/ruby/2.2.0/extensions/x86_64-linux/2.2.0/nokogiri-1.6.6.2/gem_make.out

I've tried every possible solution I found, either locally installation or gem install nokogiri doesn't work... 我已经尝试了我找到的所有可能的解决方案,无论是本地安装还是gem安装nokogiri都不起作用......

You can try : 你可以试试 :

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

bundle install

Or you can reseach sth on nokogiri doc 或者你可以研究nokogiri doc

试试这种方式:

gem install nokogiri -v 1.6.6.2 -- --use-system-libraries
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
gem install nokogiri

did it for me 为我做了

If you are using macOS Mojave, Xcode 10 on macOS Mojave moves the system headers out of /usr/include and so Nokogiri will fail to build. 如果你使用macOS Mojave,macOS Mojave上的Xcode 10会将系统头移出/usr/include ,因此Nokogiri将无法构建。 Here is a workaround from nokogiri official installing guide 这是nokogiri官方安装指南的解决方法

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

You should update your gemfile with the nokogiri gem 你应该用nokogiri gem更新你的gemfile

gem 'nokogiri', '~> 1.6', '>= 1.6.8' gem'nokogiri','〜> 1.6','> = 1.6.8'

after updating your Gemfile with the line of code above run: 用上面的代码行更新你的Gemfile后:

bundle install 捆绑安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM