Nokogiri installation fails -libxml2 is missing

前端 未结 19 2316
情书的邮戳
情书的邮戳 2020-11-27 10:22

I always worked my way around Nokogiri installation issues by following the documentation in the \"Installing Nokogiri\" tutorial.

But this time, even after installi

相关标签:
19条回答
  • 2020-11-27 10:50

    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

    0 讨论(0)
  • 2020-11-27 10:51

    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
    
    0 讨论(0)
  • 2020-11-27 10:53

    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.

    0 讨论(0)
  • 2020-11-27 10:54

    It will be:

    sudo yum install -y libxml2 libxml2-devel
    

    on RHEL servers.

    0 讨论(0)
  • 2020-11-27 10:58

    In Mac OS X (Mavericks), installing the libraries with brew and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before installing the gem did the trick for me.

    Summarising:

    • If previously installed, uninstall the gem:

      gem uninstall nokogiri
      
    • Use Homebrew to install libxml2, libxslt and libiconv:

      brew install libxml2 libxslt libiconv
      
    • Install the gem specifying the paths to the libraries to be linked against:

      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"
      
    0 讨论(0)
  • 2020-11-27 10:58

    For Windows x64:

    gem inst nokogiri --pre --platform ruby
    

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

    0 讨论(0)
提交回复
热议问题