Building Nokogiri on El Capitan
Last week I couldn’t generate one of my websites with Jekyll. After some research I noticed that it was complaining about Nokogiri. I had the problem before, but I didn’t document it well enough so I had to troubleshoot the whole process again.
It seems that everytime I have an update, security or not, compiling of Nokogiri goes wrong.
I had all sorts of error messages:
- ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension.
- Failed to build gem native extension. libxml2 version 2.6.21 or later is required!
and more I unfortunately didn’t write down.
Although the Nokogiri website had a good installation guide, it still didn’t work on my Mac.
After a lot of searching on the internet I found my solution: Compiling it to the libraries from brew.
First install the libraries with
brew install libxml2 libxslt
and then compile it with:
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir=/usr/lib --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xml2-include="$(brew --prefix libxml2)/include/libxml2" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
If you are using bundle to run Jekyll you have to configure the build settings for Nokogiri with:
bundle config build.nokogiri --use-system-libraries --with-iconv-dir=/usr/lib --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xml2-include="$(brew --prefix libxml2)/include/libxml2" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
bundle install
That did the trick for me. Now bundle installs Nokogiri without errors.
Iedere dag een nieuwe hobby? Het lijkt wel alsof A.J. hobby’s een doel op zich heeft gemaakt. Niet te beroerd om een nieuwe hobby of gadget uit te proberen en er vervolgens enthousiast en onderbouwd over te vertellen.
Een aantal van de hobby’s die A.J. ondertussen heeft gehad of nog steeds heeft: fotograferen, filmen, video editen, lezen, schrijven, houtbewerken, (technisch) tekenen, skaten, hardlopen, dansen, barbecuen.