Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby on rails - problem bundle install nokogiri 1.7.2 on ruby on rails 4.x

I have problem trying to do bundle install nokogiri 1.7.2

I am using

gem 'rails', '4.2.4'
MacOS High Sierra version 10.13.6

Im not sure what is wrong

below is my error output:

full error output:

https://gist.github.com/axilaris/68e7df57c3e29366d7a1998eebd93517

this is where the error description:

An error occurred while installing nokogiri (1.7.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.7.2'` succeeds before bundling.

In Gemfile:
  rails_admin was resolved to 1.1.1, which depends on
    rails was resolved to 4.2.4, which depends on
      actionmailer was resolved to 4.2.4, which depends on
        actionpack was resolved to 4.2.4, which depends on
          actionview was resolved to 4.2.4, which depends on
            rails-dom-testing was resolved to 1.0.8, which depends on
              nokogiri

UPDATE, didnt work with sudo gem install nokogiri

$ sudo gem install nokogiri -v '1.7.2'
Building native extensions.  This could take a while...

....

Building Nokogiri with a packaged version of libxml2-2.9.4
with the following patches applied:
    - 0001-Fix-comparison-with-root-node-in-xmlXPathCmpNodes.patch
    - 0002-Fix-XPointer-paths-beginning-with-range-to.patch
    - 0003-Disallow-namespace-nodes-in-XPointer-ranges.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.4.tar.gz into tmp/x86_64-apple-darwin17/ports/libxml2/2.9.4... OK
Running git apply with /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.7.2/patches/libxml2/0001-Fix-comparison-with-root-node-in-xmlXPathCmpNodes.patch... OK
Running git apply with /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.7.2/patches/libxml2/0002-Fix-XPointer-paths-beginning-with-range-to.patch... OK
Running git apply with /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.7.2/patches/libxml2/0003-Disallow-namespace-nodes-in-XPointer-ranges.patch... OK
Running 'configure' for libxml2 2.9.4... OK
Running 'compile' for libxml2 2.9.4... ERROR, review '/Library/Ruby/Gems/2.3.0/gems/nokogiri-1.7.2/ext/nokogiri/tmp/x86_64-apple-darwin17/ports/libxml2/2.9.4/compile.log' to see what happened. Last lines are:
...

Maybe related to this ? https://github.com/sparklemotion/nokogiri/issues/1690

UPDATE 18.9.2018

I noticed major issue with my rails environment on my laptop. i tried to create a new rails app. nokogiri causing major issues to my environment. what is the issue and how to resolve this ? https://gist.github.com/axilaris/03882e15d2cbd603279a654547752f9c

like image 966
Axil Avatar asked Sep 04 '18 14:09

Axil


People also ask

Can t install nokogiri?

Solution. Uninstall all versions of Nokogiri on your system, and then re-resolve your dependencies (using bundle or gem install ). This error can occur when a version of Nokogiri installed for a different version of Ruby is used by an unsupported version of Ruby.

What does Rails use Nokogiri for?

Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a sensible, easy-to-understand API for reading, writing, modifying, and querying documents. It is fast and standards-compliant by relying on native parsers like libxml2 (CRuby) and xerces (JRuby).

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.

Is Nokogiri a ruby gem?

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.


1 Answers

Sometimes this is a pain, I'm not even sure why this happens randomly. however, here is how I solve it most of the time.

brew unlink xz
gem install nokogiri
brew link xz

If that does not help, throws an error again with libxml2, you should do the following

brew install libxml2

and then

gem install nokogiri -- --use-system-libraries \
  --with-xml2-include=$(brew --prefix libxml2)/include/libxml2
like image 180
Kedarnag Mukanahallipatna Avatar answered Sep 19 '22 19:09

Kedarnag Mukanahallipatna