I tried setting up a nice Jekyll-based site (or theme, rather) Indigo on my up-to-date Mac today, and ran into a host of issues. I spent quite some time resolving it all, to the extent I thought this would be valuable for others to get recapped.
First, I clone repo. Install Jekyll, NodeJS and Bundler. Do bundle install
, and get hit in the face:
An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot continue.
Scroll the logs and see:
libxml2 is missing. Please locate mkmf.log to investigate how it is failing.
Run _ find / -name mkmf.log
to locate logs hoping to become wiser. Locate logs, read it, and indeed, libxml2
related errors (and a bunch others) are reflected:
package configuration for libxslt is not found
package configuration for libxml-2.0 is not found
package configuration for libiconv is not found
bundle install
logs also advice me to: Make sure that "gem install nokogiri -v '1.6.7.2'" succeeds before bundling.
, so I try it:
sudo gem install nokogiri -v '1.6.7.2'
Fails similarly. libxml2 is missing.
I start Googling for tips, and realize that I am one in a million experiencing issues installing Nokogiri on OSX.
Find two valueable resources:
- http://stackoverflow.com/questions/9134423/os-x-lion-attempting-nokogiri-install-libxml2-is-missing
- https://github.com/sparklemotion/nokogiri/wiki/What-to-do-if-libxml2-is-being-a-jerk
I educate myself, and understand I should try to override the system libriaries used during the install. OK, fair enough - I'll install & use sys. libs. for nokogiri:
brew install libxml2 libxslt libiconv
libxml2
and libxslt
seem to install fine, but for libiconv
I get errors:
Error: No available formula with the name "libiconv"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
This formula was found in a tap:
homebrew/dupes/libiconv
To install it, run:
brew install homebrew/dupes/libiconv
Based on tips in the SO thread linked above, I try to install libiconv
from source:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
Success!
Now I try to install nokogiri with sys. libs:
sudo gem install nokogiri -v '1.6.7.2' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
``
and get:
Password:
Building native extensions with: '--use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib'
This could take a while...
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/nokogiri
WTF?? Sudo!! I am the lord here! Listen to me computer, like you always do!
I must google. Educate myself. Now I'm starting to be really puzzled. It turns out:
Apparently with OSX el Capitan, there is a new security function that prevents you from modifying system files called Rootless.
(from SO)
Goddamit, more of this BS. Turns out I must reboot my Mac to Recovery mode, and disable this new System Integrity Protection (see SO thread for instructions). So I do.
I retry the command
sudo gem install nokogiri -v '1.6.7.2' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
and, guess what:
1 gem installed
Victory!!
Now I can continue to bundle install
the remaining deps, and kick off my newly setup Jekyll-based blog with the excellent Indigo theme!