nokogiri gem installation error

后端 未结 17 776
庸人自扰
庸人自扰 2020-11-30 21:04

I know there are a lot of questions about this gem but no answer has worked for me.

When I run in SSH gem install nokogiri I get this error:

<         


        
相关标签:
17条回答
  • 2020-11-30 21:45

    2020 April 6th Update:

    macOS Catalina 10.15

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

    macOS Mojave 10.14

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

    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/
    

    Consider to add sudo if you don't have permission.


    For some reason Apple’s Yosemite version of OSX does not have a system accessible installation of libxml2. Nokogiri requires this in order to compile and luckily Xcode has a version of libxml2 bundled with it — we just need to specify it when installing the gem. It’s important to get Nokogiri installed correctly because as of right now Rails 4.2.1.rc4 automatically attempts to install it and you will feel pain.

    Checkout this post for more info.

    0 讨论(0)
  • 2020-11-30 21:46

    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.

    0 讨论(0)
  • 2020-11-30 21:46

    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 
    
    0 讨论(0)
  • 2020-11-30 21:48

    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.

    0 讨论(0)
  • 2020-11-30 21:52

    This worked for me with OS X Yosemite.

    gem install nokogiri -v 1.6.5 -- --use-system-libraries
    
    0 讨论(0)
  • 2020-11-30 21:52

    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
    
    0 讨论(0)
提交回复
热议问题