nokogiri gem errore di installazione

So che ci sono molte domande su questo gioiello ma nessuna risposta ha funzionato per me.

Quando corro in SSH gem install nokogiri ottengo questo errore:

 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. 

Il mio ospite mi ha detto che tutte le librerie sono installate. Ecco i log completi dopo l’esecuzione del comando nokogiri di installazione:

 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 `' 

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/ 

Considera di aggiungere sudo se non hai il permesso.


Per qualche motivo la versione Yosemite di OSX di Apple non ha un’installazione accessibile al sistema di libxml2. Nokogiri richiede questo per compilare e fortunatamente Xcode ha una versione di libxml2 in bundle con esso – abbiamo solo bisogno di specificarlo durante l’installazione della gem. È importante che Nokogiri sia installato correttamente perché al momento Rails 4.2.1.rc4 tenta automaticamente di installarlo e sentirai dolore.

Leggi questo post per maggiori informazioni .

Infine, il problema è stato causato da nokogiri stesso spedendo il proprio libxml2 che è incompatibile con alcuni sistemi.
Quindi per installare nokogiri ho dovuto dirgli che dovrebbe usare le librerie di sistema.

L’ho installato manualmente:

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

E ha funzionato bene. Altre risposte non lo hanno risolto.

Mi sono imbattuto in questo stesso problema, a causa di una dipendenza di compilazione non elencata. Quando ho trovato la directory tmp in questione:

 find ~/.rbenv/ -name patch.log 

Ha detto:

sh: patch: comando non trovato

Risolto problema con un semplice:

 sudo yum install -y patch 

Su OSX Yosemite, ho fatto xcode-select --install in un terminale. Dopo di che, bundle funzionato bene con quella gem.

Questo funziona per me in Windows 7 Home Basic 64 bit:

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

Questo ha funzionato per me con OS X Yosemite.

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

Questo è ciò che ha funzionato per me su 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 

Proprio come wongzigii dice che il comando install funziona con quei flag con 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/

Niente nelle risposte attuali ha funzionato per me (io uso Ubuntu 16.04, non Mac).

Tuttavia, seguendo le istruzioni nel sito di Nokogiri e questa parte ha fatto il trucco:

 # 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 

Nota Sto usando Nokogiri dal 2009 e ho sempre avuto problemi nell’installarlo. Qualche ulteriore commento probabilmente non sarebbe conforms a SO T & Cs 🙂

Installazione di 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

Funziona per me 🙂

Nokogiri non ha trovato le librerie Xcode sulla mia macchina OSX Sierra finché non ho eseguito:

sudo xcodebuild -license accept

Questo ha funzionato per 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 

Alla fine, dopo molte lotte, ho lavorato per me (OS X 10.8.5, macports). (Sto installando pagine github ie 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 

Sto usando macOS Sierra.

Sono andato alla documentazione di nokogiri e ho seguito questo:

SU MAC OSX

L’installazione dovrebbe essere Just Work ™ usando libxml2 e libxslt venduti da Nokogiri.

Prima di tutto, assicurati di avere l’ultima versione di RubyGems e degli strumenti della riga di comando xcode:

1 gem update --system

2 xcode-select --install

Quindi installa nokogiri:

1 gem install nokogiri