Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 972
user7406101 Avatar asked Oct 31 '17 15:10

user7406101


2 Answers

I'm just posting the solution I found (I had the same problem on MacOS). With this, the gem will be installed using the system libraries, which should solve the probleme you encountered.

  1. If using gem:
gem install nokogiri -- --use-system-libraries
 [--with-xml2-config=/path/to/xml2-config]
 [--with-xslt-config=/path/to/xslt-config]
  1. If using bundle:
bundle config build.nokogiri --use-system-libraries
bundle install
like image 162
cba Avatar answered Oct 03 '22 18:10

cba


On high sierra (and mojave), this worked for me

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/

bundle update

bundle install
like image 39
stevec Avatar answered Oct 03 '22 19:10

stevec