Foggy CarrierWave Nokogiri woes on Mac OS X Snow Leopard

I’m developing a Ruby on Rails app on my Mac running Snow Leopard. Tonight I wanted to use the fog gem with CarrierWave to upload files to Amazon S3.

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
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 -o libxslt-1.1.26.tar.gz
tar zxfv libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure \
--prefix=/usr/local/Cellar/libxslt/1.1.26 \
make install
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 -- \
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 \
--with-xml2-include=/usr/local/Cellar/libxml2/2.7.7/include/libxml2 \
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.7/lib \

Now everything seems to be working ok.


Test Flight – Easy Beta Distribution for iOS Apps

At the April 2011 Melbourne Cocoaheads meetup I presented a talk on using Test Flight. Test Flight is an online service for iOS app developers that makes distributing betas easy and fairly painless.

You can watch the talk below or in HD on Vimeo.

Here are the slides for this talk.

Why I buy Apple computers.

I recently saw this post on TUAW about why the author stays with Apple gear even when it annoys him. I thought I’d add my voice to the chorus by relating my recent experience dealing with Apple customer service and describe why it is just so damn awesome.

In 2009 my father had a very bad accident and was in hospital and rehab for months. As such he wanted a laptop computer to use. So I bought him a MacBook Pro 15″. I kitted this Mac out with a few options making it quite an expensive purchase.

A few months after purchase my father returned home with this laptop and we discovered that the Airport Express card in the laptop was unreliable. My parents live in a small town in New Zealand and there is no local Apple store. There is however a reseller and authorised service provider. We handed the Mac over to them for them to replace the Airport Express card which they did under Applecare for no cost.

Unfortunately after the Mac was returned to my father it became less and less reliable. My father though, not being the complaining type, didn’t express exactly how bad the problem was to me. It wasn’t until this Christmas when I was visiting my parents that I discovered how bad the problem with the MacBook had become. It was locking up very regularly.

Unfortunately by this time the MacBook was out of AppleCare. So I just bought my father a new MacBook Air and took away the MacBook Pro. The MacBook Pro was only two years old but I was not hopeful about getting the problem with it solved.

With that in mind I visited the Apple Store in Chadstone to talk to them about getting the MacBook fixed. Fortunately for me I could demonstrate the problem with the laptop in front of the Apple Genius I spoke to and he was more than happy to make an exception and accept the MacBook for repair at no cost to me. Keep in mind that I did not have AppleCare for this MacBook anymore.

About a week later I was telephoned by the Apple Genius doing the repair work and informed that they had discovered what the problem was. It all stemmed from the original AirPort Express card “repair”. It had been completely botched. When they disassembled the MacBook for this original repair they had broken the connector between the mother board and the hard disk drive.

Because of this botched repair the Genius had decided to investigate further and had discovered more problems. The original “repairer” had also damaged the connector between the LCD panel and the motherboard. They had also not applied the thermal grease that should have been on the AirPort Express card to improve heat dissipation.

While these parts where not at present “broken”, the Genius, realising that this repair was all covered for no cost even outside of AppleCare, decided that the LCD panel and AirPort Express should be replaced “in case they failed in future”.

So today I’m going to pick up my dad’s old MacBook Pro that has had nearly its entire guts replaced. The only thing left of the old unit is the case, keyboard and optical drive. All of this outside of an AppleCare warranty and at no cost to me. This is real customer service.

In contrast to this, my 18 month old PlayStation 3’s power supply recently failed. To get this fixed I had to fork out $250 to Sony for a replacement refurbished PS3.

Also, my brother’s HP laptop (again only 18 months old) keyboard failed. HP would not cover this $45 replacement part or do the 10 minute repair job to replace the keyboard.

Window Management in MacOS X (Part 1)

My father is a fairly in-experienced Mac OS X user. In order to help him out I decided to create some tutorial screen casts describing some of the features of Mac OS X he has trouble with or doesn’t know much about. I’m guessing that these screencasts might be useful to more people, so I’ll be posting them here via Vimeo.

Here is part one of a tutorial on Window Management in MacOS X.

You can watch in high definition on Vimeo.

February Melbourne Cocoaheads – Part 2

Thursday the 10th last week was the first Melbourne Cocoaheads meetup of the year. Two talks were given. The first was a talk by Stewart Gleadow on the topic of Frank (see the previous blog post). The second talk was by Jeff Tan-Ang of AppsPerhaps. His talk was regarding his company’s iPhone app, OzTV. This slick TV Guide application leads the Australian App Store’s “Lifestyle” paid application category. In the video I’ve created below he discusses the sales performance of the app in the store and the lessons he and co-creator Alex Johnston learned.