ruby gem nokogiri version 1.12.5 install error: 'gumbo.h' file not found

Viewed 178

I tried changing the gemfile to use a newer version of nokogiri as well as resolve dependencies by brew installing libxml2 and libslt, but nothing worked. Here is the error message:

gumbo.c:32:10: fatal error: 'gumbo.h' file not found
#include "gumbo.h"
         ^~~~~~~~~
1 warning and 1 error generated.
make: *** [gumbo.o] Error 1
3 Answers

I had the same issue. Not a satisfying answer, but I uninstalled everything and did a clean install using rbenv and it worked.

I had a similar problem. After reading the nokogiri installation instructions, I learned something!

Nokogiri provides precompiled binaries for most things. Now if you switch from Mac to Linux or vice versa, your Gemfile.lock may have a platform list which doesn't include your current platform.

The command that fixed it for me was

bundle lock --add-platform arm64-darwin

Then, bundle just downloaded the precompiled version.

My recommendation is to work out how to install the precompiled version for your platform. When I ran gem install nokogiri that is what happened, but because of the platform list in the Gemfile.lock it wasn't doing that and instead wanted to compile it.

The solution for me on my M1 Macbook was by using rbenv but first:

  1. Uninstall bundler: gem uninstall bundler
  2. Uninstall rbenv: rbenv uninstall YourRubyVersion and then brew uninstall rbenv

(YourRubyVersion you can find it by executing ruby -v)

  1. Delete the Gemfile.lock file.

After that:

brew install rbenv

rbenv install RubyVersion

rbenv init

rbenv global RubyVersion

bundle install

Related