development

Nokogiri 설치 실패 -libxml2가 없습니다

big-blog 2020. 6. 8. 07:59
반응형

Nokogiri 설치 실패 -libxml2가 없습니다


" Nokogiri 설치 "학습서 의 문서에 따라 항상 Nokogiri 설치 문제를 해결했습니다 .

그러나 이번에는 모든 종속성을 설치 한 후에도 Nokogiri가 설치되지 않았습니다. 다음과 같은 오류가 발생합니다.

libxml2 is missing.  please visit <http://nokogiri.org/tutorials/installing_nokogiri.html>

libxml2 및 libxslt 디렉토리를 지정하여 설치를 시도했습니다.

sudo gem install nokogiri -- --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib --with-xslt-dir=/usr/

그러나 같은 오류가 반환되었습니다.

나는 다른 모든 관련 스택 오버플로 기사를 따랐으며 도움이되지 않았습니다. 누구든지 해결책이 있습니까?


먼저, 의존성을 설치하십시오 :

sudo apt-get install libxslt-dev libxml2-dev

여전히 오류가 발생하면 컴파일러 툴체인이 누락 된 것일 수 있습니다.

sudo apt-get install build-essential

빌드 툴체인이 없으면 "libxml2가 없습니다"오류가 발생합니다 (적어도 Debian Lenny에서이 문제가 발생했습니다).

Nokogiri 빌드는 libxml2 헤더 파일이 존재하는지 검증하기 위해 libxml2 헤더 파일을 테스트 컴파일하지만 "libxml2가 없음"과 "libxml2를 테스트하는 컴파일러가 없음"을 구분하지 않습니다.


실제로이 두 패키지를 모두 설치해야 할 수도 있습니다

sudo apt-get install libxslt-dev libxml2-dev

Mac OS X (Mavericks) 에서 gem을 설치하기 전에 라이브러리를 설치 brew하고 설정 NOKOGIRI_USE_SYSTEM_LIBRARIES=1하면 나에게 트릭이되었습니다.

요약 :

  • 이전에 설치 한 경우 gem을 제거하십시오.

    gem uninstall nokogiri
    
  • 설치 브루를 사용 libxml2, libxsltlibiconv:

    brew install libxml2 libxslt libiconv
    
  • 연결할 라이브러리의 경로를 지정하여 gem을 설치하십시오.

    NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
    

방금 Fedora 13에서 동일한 문제가 발생했습니다. 좌절하고 실패한 검색 후

gem install nokogiri

나를 위해 일하고, 그것을 설치하고를 통해 libxml2 오류를 해결할 수있었습니다 yum.

명령 yum대신 gem을 설치하기 만하면 됩니다 gem.

su
yum search rubygem-nokogiri   #this find the proper package name
yum install rubygem-nokogiri.i686

이는 Fedora에 대한 정답을 찾는 데 도움이되었으며 Ruby 패키지 관리에 RVM을 사용하면서

yum install rubygem-nokogiri

RVM 환경이 아닌 시스템에 모든 Ruby gem과 종속성을 가져오고 매우 실망스럽고 겸손한 경험을하게됩니다.

따라서 Nokogiri yum 보석을 찾으면 다음을 사용할 수 있습니다.

yum provides  rubygem-nokogiri

rubygem-Nokogiri의 종속성 목록을 가져와 누락 된 라이브러리를 보여주십시오. 그 후 나는 달렸다.

yum install libxml2-devel libxslt libxslt-devel

이제 Nokogiri가 Fedora 및 Nokogiri 설치에서 컴파일됩니다. D' oh !, 개발 라이브러리에서 Nokogiri를 컴파일하려면 헤더가 필요합니다.


일반적으로 gem을 빌드하기위한 개발 파일이 필요합니다. 시험:

sudo apt-get install libxslt-dev libxml2-dev

(방금 에릭이 같은 의견을 제시 한 것을 보았습니다.)


Mac OS X (Mavericks)에서 이러한 솔루션이 작동하지 않으면 다음을 시도하십시오.

ARCHFLAGS="-arch x86_64" gem install nokogiri

또는

ARCHFLAGS="-arch i386" gem install nokogiri

depending on your system's architecture.


I was able to get this installed with Chocolatey, Windows 8.1 x64, and DevKit x64.

cinst libxml2
cinst libxslt
cinst libiconv

gem install nokogiri -- 
  --with-xml2-include=C:\Chocolatey\lib\libxml2.2.7.8.7\build\native\include 
  --with-xml2-lib=C:\Chocolatey\lib\libxml2.redist.2.7.8.7\build\native\bin\v110\x64\Release\dynamic\cdecl 
  --with-iconv-include=C:\Chocolatey\lib\libiconv.1.14.0.11\build\native\include 
  --with-iconv-lib=C:\Chocolatey\lib\libiconv.redist.1.14.0.11\build\native\bin\v110\x64\Release\dynamic\cdecl 
  --with-xslt-include=C:\Chocolatey\lib\libxslt.1.1.28.0\build\native\include 
  --with-xslt-lib=C:\Chocolatey\lib\libxslt.redist.1.1.28.0\build\native\bin\v110\x64\Release\dynamic

You'll have to verify the version number in the paths are correct.

You may possibly need to add Microsoft's NuGet repository:

-Source "https://go.microsoft.com/fwlink/?LinkID=230477"

It will be:

sudo yum install -y libxml2 libxml2-devel

on RHEL servers.


At macOS none of above/below had really worked for me until I explicitly provided XCode libxml2 path to --with-xml2-include.

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

I was able to install Nokogiri 1.6.5 on Fedora 20 by doing:

export NOKOGIRI_USE_SYSTEM_LIBRARIES=true

Then running:

gem install nokogiri

For anyone else experiencing this issue, I solved it by running this command within the project directory

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

Update: I ran into this again and tried just updating the gem which worked for me...

gem update nokogiri


Have you tried installing libxml2? Not from rubygems, but via the standard install process for your operating system. On Ubuntu/Debian for example:

sudo apt-get install libxml2

On any recent version of OS X it should already be installed.


For OSX users, if you've had success installing Nokogiri before, yet are getting errors installing it on, say, using a new version of Ruby that you've added and that error that includes a message like:

The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

This could be indicative of a XCode upgrade having happened via the App Store, either manually or automatically, and you not having opened it since that time.

If so, you should be able to open XCode, agree to the new license, and then install Nokogiri successfully.


On Mac OS X Yosemite my mistake was that I tried to use sudo gem install when it's a rule of thumb to not use superuser privileges when installing gems.

In my case it tried to modify the system installation of Ruby, and that's not a good idea. I installed rbenv, installed Ruby 2.2.2 thru it and set it as global, which is a term from rbenv's documentation. After that Nokogiri could install itself with a simple

gem install nokogiri

No hacks or workarounds were necessary, just a properly set environment; Nokogiri does the rest perfectly.


Was able to install vagrant-awe by following the above post but using the command as follow:

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 vagrant plugin install vagrant-aws

For Windows x64:

gem inst nokogiri --pre --platform ruby

For more information check this thread: https://github.com/sparklemotion/nokogiri/issues/864


I was able to install Nokogiri by running the following packages:

$ dnf group install "C Development Tools and Libraries"
$ dnf install ruby-devel libxml2-devel patch

=== TLDR ===

As the instructions state, build Ruby with the latest clang compiler, or at least the same version that Rubygems will use to compile Nokogiri's native extensions libxml and libxsl.

If using RVM, building from source with the --with-ggc=clang flag was what did it for me:

rvm install 2.2 --with-gcc=clang

Replace 2.2 with whatever version you want. --with-gcc=clang ensures RVM builds from source and uses clang to do so; otherwise RVM may a pre-built binary Ruby, which is what tripped me up.

Then, install Nokogiri as normal using Bundler or Rubygems.

=== IN DEPTH ===

I struggled with this for a while. gem install nokogiri gave me:

checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no

Digging into mkmf.log I saw:

conftest.c:15:27: error: too few arguments to function call, single argument 'cur' was not specified
int t(void) { xmlParseDoc(); return 0; }  

Nokogiri supplies its own libxml and libxsl (as of 1.6.4). The signature defined in Nokogiri's local copy of parser.h (found under the gem install directory) is:

xmlParseDoc (const xmlChar *cur);                                                                                                                                                                                

So I was at a loss as to how the method call in the hermetically sealed conftest.c file usage couldn't match up with the header file for parser.h.

When I realized I had probably installed a binary Ruby I removed and reinstalled using --with-gcc=clang (to force compilation and use clang) and the problem was solved:

rvm uninstall 2.2
rvm install 2.2 --with-gcc=clang
gem install nokogiri

I'm not exactly sure why that works as the system libxml header /usr/include/libxml2/libxml/parser.h has the same signature as Nokogiri's local copy.

It's weird, but it worked. Just make sure you compile a Ruby with clang.


gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib

Change your version with it.

참고URL : https://stackoverflow.com/questions/6277456/nokogiri-installation-fails-libxml2-is-missing

반응형