Broken unison brew on Yosemite

I rely on Homebrew for many of the command line tools I use on my computers. One such tool is unison, a powerful synchronisation application for keeping files in synch. I use it as a way to allow me to work on any one of my computers with maintained security and without having to send my files to a cloud provider. These days there are several alternatives with Bittorrent Sync as probably the best option.

One caveat with unison is that it requires all peers to use the same version of the binary. But with a limited number of peers this is not a major issue.

For a long time I just used precompiled binaries for OS X and Ubuntu using the same unison version. Then, as I reinstalled the Ubuntu server and got a newer version I realised that this was the same version (2.40.102) that was installed with brew so I ditched the previous binaries and installed unison using brew instead. That worked for two OS X computers but on the third one I got an error when synchronising the files:

Uncaught exception Failure("input_value: bad bigarray kind")

This exception occurred on a completely reinstalled Macbook. The exception seems to be caused by unison using an incompatible version of ocaml compared with the ones on my other computers (the brew version is compiled against ocaml v4.02 while my other clients were using 4.01).

As I see it there are two potential solutions to this problem:

  1. Upgrade all peers to the new ocaml version
  2. Build a version of Unison using the older (<4.02) version of ocaml

For this article I chose the latter alternative.

First, I needed to install version 4.01 of ocaml. Brew will by default use the most recent stable version (right now 4.02) but can be made to install older versions if required. To list the existing versions run:

$ brew versions ocaml

4.02.1   git checkout a772c80 /usr/local/Library/Formula/objective-caml.rb
4.01.0   git checkout 924387b /usr/local/Library/Formula/objective-caml.rb
4.00.1   git checkout b04e346 /usr/local/Library/Formula/objective-caml.rb
4.00.0   git checkout e2140fd /usr/local/Library/Formula/objective-caml.rb
3.12.1   git checkout df16522 /usr/local/Library/Formula/objective-caml.rb
3.12.0   git checkout 0476235 /usr/local/Library/Formula/objective-caml.rb
3.11.2   git checkout ed51a5b /usr/local/Library/Formula/objective-caml.rb

If the versions command above shows ‘Error: Unknown command’ then just run

$ brew tap homebrew/boneyard

After that, run the versions command again and it should work. This will display a warning that brew-versions is unsupported. Ignore this for now and notice the line with version 4.01.0.

$ cd `brew --prefix`/Library
$ git checkout 924387b /usr/local/Library/Formula/objective-caml.rb
$ brew install ocaml

Now we should have ocaml v4.01.0. Then, compile unison from source in a temporary directory that you can remove afterwards:

$ cd /tmp
$ wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/unison-2.40.102/unison-2.40.102.tar.gz
$ tar -xvzf unison-2.40.102.tar.gz
$ cd unison-2.40.102
$ make UISTYLE=text
$ sudo cp unison /usr/local/bin/

Now you should have a working unison installation using ocaml 4.01.0

Featured photo by Giuseppe Milo (https://www.flickr.com/photos/giuseppemilo/15602907800).

One thought on “Broken unison brew on Yosemite”

Comments are closed.