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.
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.
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
bundle config build.nokogiri --use-system-libraries
bundle install
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With