Fog is a Ruby wrapper around different cloud services and CarrierWave provides a very nice API for handling file uploads in Rails apps.
Fog has a dependency on the Nokogiri HTML/XML parsing library, which has a dependency on libxml2, libxslt, and libiconv.
Welcome to pain and suffering…
The versions of libxml2 and libxslt on MacOS X are a little out of date. And when trying to install the nokogiri gem with:
sudo gem install nokogiri
You will get an error like this:
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
libiconv is missing.
please visit http://nokogiri.org/tutorials/installing_nokogiri.html
for help with installing dependencies.
Now, libiconv isn’t missing. It is installed with MacOS X. But nokogiri’s build script can’t find it for some reason.
The Nokogiri install instructions suggest installing newer versions of libxml2 and libxslt to solve this problem. They even kindly provide instructions for a number of operating systems including MacOS X.
Unfortunately none of them worked for me.
I’m using homebrew to manage my additional source packages on my Mac. Installing libxml2 via homebrew is easy:
brew install libxml2
Installing libxslt, not so much.
There is no brew formula for libxslt in the default homebrew git repo. I have no idea why. Perhaps something to do with homebrew’s policy not to dupe stuff bundled with MacOS X. Not sure why they provide a libxml2 forumla then as it comes with MacOS X too.
So to install libxslt I did the following:
curl ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz -o libxslt-1.1.26.tar.gz
tar zxfv libxslt-1.1.26.tar.gz
cd .. && rm -rf libxslt-1.1.26 && rm -f libxslt-1.1.26.tar.gz
To install nokogiri I then used the following command line.
sudo gem install nokogiri -- \
Now everything seems to be working ok.