Search code examples
ruby-on-railsnokogiri

Nokogiri v 1.8.1 issue when running Bundle Install


When running Bundle Install or Gem Install Nokogiri, I get the same issue which is preventing my app from running. I suspect this issue is local and came from moving everything up to Rails 5, but I'm not sure. Here is the error message:

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

In Gemfile:
  rails_admin was resolved to 1.2.0, which depends on
    rails was resolved to 5.1.3, which depends on
      actioncable was resolved to 5.1.3, which depends on
        actionpack was resolved to 5.1.3, which depends on
          actionview was resolved to 5.1.3, which depends on
            rails-dom-testing was resolved to 2.0.3, which depends on
              nokogiri

(That comes from running Bundle Install) I've tried running Bundle Update and using various Homebrew commands recommended by Github, but I haven't had any success.

gem install nokogiri -v '1.8.1'

1 error generated.
make[2]: *** [xmlIO.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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.

Solution

  • Nokogiri fails to build normaly because you don't have dev libraries like libxml2. Look at the log file to see what happens or try to install libxml2 directly with brew install libxml2

    See throubleshoting guide provided by Nokogiry at http://www.nokogiri.org/tutorials/installing_nokogiri.html