I have a file server running Raspbian 9, and use Unison over SSH to sync my home dir between these two.

This has worked well for the two years I was on Ubuntu 18.04, but after upgrading to Ubuntu 20.04, syncing over SSH aborts with an unmarshaling error, claiming the two Unison versions (local and remote) were built with different OCaml versions.

Unison version is 2.48 on all systems involved (pre and post upgrade).

What gives?

1 Answer 1



Using Unison over the network greatly speeds up synchronization across the network (as files are scanned for changes locally rather than over the network), but it requires matching Unison versions on both ends. As Unison relies on some OCaml libraries to do the synchronization, and as these libraries are apparently not guaranteed to be stable across OCaml versions, both ends need to be running not only the same Unison version, but the same Unison version built with the same OCaml version. (Yes, that is a bummer, and the Unison project has multiple issues on this: #375 is about the protocol being dependent on the OCaml version used for the build; it is currently being worked on but still open as of Unison 2.51.3. #407 is about the assumption that the wire protocol changes with every version.)

As far as I can see, Raspbian 9 (Stretch) ships with OCaml 4.02, Ubuntu 18.04 ships with OCaml 4.05, and Ubuntu 20.04 ships with OCaml 4.08. Presumably Unison gets build on the default OCaml version for the platform, but 2.48 doesn’t tell us that yet (later versions report their OCaml version). While apparently 4.05 happens to be compatible with 4.02, a compatibility-breaking change seems to have been introduced by 4.08.

The Unison project offers some binaries from their CI, and later versions allow choosing between different OCaml versions. Unfortunately, this is not available for the armhf architecture, and not yet for Unison 2.48, so that doesn’t help here.

Short-term solution (available right now)

For the moment, downgrading Unison on the Ubuntu machine to the version that shipped with 18.04 worked for me. (The package has minimal dependencies, other than a minimum version of libc.)

Grab unison-gtk_2.48.4-1ubuntu1_amd64 from the Ubuntu repos (this is the release that ships with 18.04; 20.04 has unison-gtk_2.48.4-4ubuntu1_amd64), and install it with:

sudo dpkg -i ~/Downloads/unison-gtk_2.48.4-1ubuntu1_amd64.deb

In order to prevent the updater from undoing your changes on its next run, put the package on hold:

sudo apt-mark hold unison-gtk

(If you decide to upgrade in the future, re-running this command with unhold will undo this, allowing the package to be upgraded again.)

You may have to delete your Unison cache—~/.unison/ar* and ~/.unison/fp*—on both ends.

For now, Unison will work again.

Short-to-mid-term solution (~mid-2021)

The upcoming Debian 11 (Bullseye) includes Unison 2.51. The way to go would then be to update the file server to Debian 11 and Unison 2.51, and for any workstation grab a binary build from Unison’s CI, with the matching program and OCaml version. Given the previous release cycles of Debian, it’s somewhat realistic for Bullseye to be released sometime in early/mid 2021.

Mid-to-long-term solution (2022–2023)

As I understood the corresponding issue, removing OCaml version dependencies from the wire protocol is just around the corner. The way to go would then to just have matching Unison versions on both ends (provided it is a version that has eliminated the dependency). It will probably take a while for your favorite distro to carry such a version after it is released, though—we’re probably talking about sometime between April 2022 and mid-2023.

Long-term solution

The Unison team are also working on assigning wire protocol version numbers separately from program versions, so several versions will eventually share the same version of the wire protocol, as long as the protocol does not indeed change. Once that happens, even different Unison versions will be able to work together, as long as both use the same protocol version.

Update as of 2024

Unison versions 2.52 and higher are compatible between each other. They are also compatible with 2.51 and 2.48, as long as both Unison versions were built against the same OCaml version. On Unison 2.51, unison -version will tell you what OCaml version Unison was built with. On 2.48, you will have to guess. If that version came from your OS repo, then the OCaml version on the repo is your best bet.

So, your best bet is to upgrade to Unison 2.52 or higher on both ends. If you can do that only on one end, you can upgrade just that end but ensure both ends were built against the same OCaml version.

See chapter 3 of the Unison manual on upgrading.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .