Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nokogiri gem installation error

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:

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. 

My host told me that all libs are installed. Here are the full logs after executing the install nokogiri command:

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>' 
like image 239
Claudiu Creanga Avatar asked Jun 16 '14 20:06

Claudiu Creanga


People also ask

What is GEM Nokogiri?

The Nokogiri gem is an incredible open-source tool that parses HTML and XML data. It is one of the most widely used gems available, and it can really take your Ruby app to another level for data with its ability to help you intuitively scrape websites.

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

What is Nokogiri used for?

Nokogiri (htpp://nokogiri.org/) is the most popular open source Ruby gem for HTML and XML parsing. It parses HTML and XML documents into node sets and allows for searching with CSS3 and XPath selectors. It may also be used to construct new HTML and XML objects.

Where to install Nokogiri gem file?

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection. Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out

Why can't I install Nokogiri?

Have you tried gem install nokogiri -v 1.6.5 -- --use-system-libraries ?Most nokogiri errors are to do with libxml2, libxslt or libiconv config. Nokogiri docs should give you more instructions. If the solution doesn't work, you may want to post full stack trace so others can help more. Show activity on this post.

What version of Ruby does Nokogiri require?

Using mini_portile (0.5.0) Installing nokogiri (1.6.0) Gem::InstallError: nokogiri requires Ruby version >= 1.9.2. An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling. › rbenv version 1.9.3-p429 (set by /Users/andrewguo/.rbenv/version)

How do I know if my system supports native gems?

To determine whether your system supports one of these gems, look at the output of bundle platform or ruby -e 'puts Gem::Platform.local.to_s'. If you're on a supported platform, either gem install or bundle install should install a native gem without any additional action on your part.


1 Answers

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.

like image 127
Zigii Wong Avatar answered Sep 21 '22 12:09

Zigii Wong