Why won’t Nokogiri install ever

Nokogiri is always the thing to break bundle install. Why?!

This time I read the output. Always do that, don’t try to avoid it.

Reading and interpreting and googling the messages led me to forming meaningful search queries, finding useful posts and feeling like I understood the problem better (which…yeah, of course).

The important error in the output was:

ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.

Potential solution that didn’t work for me

One article suggested that I may need to explicitly point to libxml2 which had been installed via Homebrew (so I could get the path with brew list libxml2) although I wasn’t able to form a command that worked:

gem install nokogiri -- --use-system-libraries --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib
gem install nokogiri -- --use-system-libraries --with-xml2-lib=~/usr/local/Cellar/libxml2/2.9.2/lib

No ~? Don’t we need to start at the root?

Potential solution that did work for me

reinstalled/updated xcode dev tools. These commands worked:

xcode-select --install
gem install nokogiri
bundle install

ETA 18-10-2016

Had this issue again with the same error message. The following commands worked:

bundle install (failed)
(sudo) xcode-select --reset which “resets to the default command line tools path”
gem install nokogiri
bundle install (worked)