Tuesday, March 6, 2012

couchdb on Mac OS X

I've started to work with couchdb.

I've blogged before about the problems of SQL schema in Escaping the Relational Schema Trap.

A SQL schema -- for many applications -- is too confining.  It creates cost with relatively little value.  Once upon a time (when disks where expensive and computers were slow) it was essential.

The funny part about using couchdb is the build process.

In the couchdb Wiki, they have a page for Mac OS X installation.  The relevant part is the following line of shell script.

brew install couchdb

That's it?

Yes.  If--and only if--you follow the directions.

If you don't follow the directions, however, it can take all day.  Here are the steps.

  1. Install Apple's Developer Tools.  I have Mac OS X 10.7.  XCode 4.3 for Lion.
  2. Launch XTools and install the command-line utilities.  This is important because it includes things like make.
  3. Remove fink or MacPorts if you happened to have used them for anything.  For fink, you'll need to clean it out of your ~/.profile or ~/.bash_profile and rename the /sw directory.
  4. Install Homebrew.   Use the one-line ruby script from the Installation page of the Homebrew wiki.  This: /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" I tried several wrong ways before doing it the right way.
  5. Install couchdb using homebrew.  It takes a while.
There are numerous things which may go wrong.

A missing lib/crt.1.10.6.o, for example. This is just an out-of-date Xcode. It took few hours of failed experiments to (a) realize it and (b) get the right one.  There are several proposed solutions around the web.  Most of them are clever, but ineffective.  Just get the right Xcode.

A failure to build Erlang. This was just an improperly installed version of Homebrew.  There were a lot of message.  A lot.  I messed around with a lot of things until I finally crashed brew doctor. I deleted and reinstalled Homebrew and everything built.  First try.