programing tip

nokogiri gem 설치 오류

itbloger 2020. 11. 19. 07:53
반응형

nokogiri gem 설치 오류


이 보석에 대해 많은 질문이 있지만 대답이 저에게 효과가 있다는 것을 알고 있습니다.

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.

내 호스트는 모든 라이브러리가 설치되어 있다고 말했습니다. 다음은 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>'

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을 설치할 때 지정하면됩니다. 현재 Rails 4.2.1.rc4가 자동으로 설치를 시도하고 고통을 느끼기 때문에 Nokogiri를 올바르게 설치하는 것이 중요합니다.

Checkout this post for more info.


Finally, the problem was caused by nokogiri itself by shipping it's own libxml2 that's incompatible with some systems.
So to install nokogiri I had to tell it that it should use the system libraries.

I installed it manually by:

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

And it worked well. Other answers didn't solve it.


I ran into this same problem, because of an unlisted build dependency. When I found the tmp directory in question:

find ~/.rbenv/ -name patch.log

It said:

sh: patch: command not found

Fixed that with a simple:

sudo yum install -y patch

On OSX Yosemite, I did xcode-select --install in a terminal. After which, bundle worked fine with that gem.


This works for me in Windows 7 Home Basic 64 Bit:

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

This worked for me with OS X Yosemite.

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

Nothing in current answers worked for me (I use Ubuntu 16.04, not Mac).

However, by following the instructions in Nokogiri site and this part did the trick:

# 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

Note I've been using Nokogiri since 2009 and I've always had trouble installing it. Any further comment would probably not comply with SO T&Cs :)


Installing Nokogiri in Mac OS El Capitan:

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

bundle install

It working for me :)


This is what worked for me on OS X 10.10.3 Yosemite:

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

Just Like wongzigii says the install command works with those flags with 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/


Nokogiri didn't find Xcode libs on my OSX Sierra machine until I ran:

sudo xcodebuild -license accept


This worked for me:

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

Finally after much struggle the following worked for me (OS X 10.8.5, macports). (I am installing github pages i.e. 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 

In my case, I am using Mac OSX Mojave and had to install a package described here: https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624

Here is the path to the package: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

After installing it, the installation finished without problems.


I figured this out the hard way and took a few hours to follow the breadcrumbs and read up on what people were trying out. Nothing helped. Everything on this overflow page just didn't help so here's how I fixed this:

If you use your machine for other development projects that aren't in ruby. You might want to check package manager installations for other languages. More importantly - you might want to check for other c compiler installations - namely clang

In my case - I had installed anaconda/conda(python) and this replaced a bunch of paths in my .bash_profile to use clang as the main c compiler where as xcode command line tools and rebenv were all using gcc installed through Homebrew earlier.

I removed anaconda(using anaconda-clean) and the clang installation and then tried to bundle. That's when I got the missing libxml2 issue. I then REINSTALLED libxml2 through homebrew to ensure the symlinks would be redone through homebrew and followed the instructions that followed to add the appropriate export flags to my ~/bash_profile file.

Successfully bundles now. The reason is, the gems are now being bundled with the same compiler as the ruby version I am using for that project.

Docker would have made this a non issue for a polyglot dev machine like many of us I assume.

So heads up.


step 1:

brew install libxml2

Step 2:

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

Step 3: then try

bundle install


Am using macOS Sierra.

Went to nokogiri documentation and followed this:

ON MAC OSX

Installation should Just Work™ using Nokogiri’s vendored libxml2 and libxslt.

First, make sure you have the latest version of RubyGems and xcode commandline tools:

1 gem update --system

2 xcode-select --install

Then install nokogiri:

1 gem install nokogiri

참고URL : https://stackoverflow.com/questions/24251494/nokogiri-gem-installation-error

반응형