git-annex/ tips/ Building git-annex on Debian OR %¤#"¤%&"# Haskell!

I've been wrestling with git-annex to try to make it build on Debian, or more specifically, wrestling with Haskell dependencies.

After a fair amount of futzing around, and pestering a bunch of people in the process (thanks for the help! :) ) I finally managed to make it build.

I figured I would post the steps here, since it's not completely trivial, and I expect that a few others might be interested in building newer versions as well.

There appears to currently be two methods:

- Debian packages on Wheezy plus Sid
  - Starting out on Wheezy, and then picking the rest from Sid (it seems at least libghc-safesemaphore-dev from Sid is critical for newer git-annex)
  - WebDAV suport will not be available with this method
- Cabal packages

# Debian packages on Wheezy plus Sid

## Start off with a clean wheezy chroot

    sudo debootstrap wheezy debian-wheezy
    sudo chroot debian-wheezy

## Install some build tools

    apt-get update
    apt-get install devscripts git

## Get git-annex (either by cloning or simply moving the source into the chroot)

    mkdir /src
    cd /src
    git clone git://git-annex.branchable.com/source.git git-annex
    cd git-annex

## Remove WebDAV dependency which can't be satisfied anywhere

    sed '/libghc-dav-dev/d' -i debian/control

## Create dummy build-depends package and install all available Wheezy dependencies using it

    mk-build-deps
    dpkg -i git-annex-build-deps*.deb
    apt-get install -f

(this will remove the build-depends package)

## Add Sid sources and install all available Sid dependencies

    echo "deb http://http.debian.net/debian sid main" >>/etc/apt/sources.list
    apt-get update
    dpkg -i git-annex-build-deps*.deb
    apt-get install -f

(the build-depends package should now be fully installed)

## Disable the 'make test' that fails due to missing hothasktags

    echo >>debian/rules
    echo "override_dh_auto_test:" >>debian/rules

## Build!

    debuild -us -uc -Igit

# Cabal packages

## Start off with a clean Sid(/Wheezy) chroot

    sudo debootstrap sid debian-sid
    sudo chroot debian-sid

## Install a smaller set of tools and build-depends from Debian (cabal needs these to compile the Haskell stuff)

    apt-get update
    apt-get install ghc cabal-install devscripts libz-dev pkg-config c2hs libgsasl7-dev libxml2-dev libgnutls-dev c2hs git debhelper ikiwiki perlmagick uuid rsync openssh-client fakeroot

## Get git-annex (either by cloning or simply moving the source into the chroot)

    mkdir /src
    cd /src
    git clone git://git-annex.branchable.com/source.git git-annex
    cd git-annex

## Install the Haskell build-dependencies from cabal

    cabal update
    cabal install --only-dependencies

## Optional step which doesn't work (might in the future)

If we want to run the 'make test' after build we need hothasktags, which is only available via cabal

    apt-get install happy
    cabal install hothasktags
    export PATH=$PATH:~/.cabal/bin

But this currently fails silently inside make test->fast->tags, and if you dig a bit (manually edit the makefile to be more verbose) you see

    hothasktags: ./Command/AddUnused.hs: hGetContents: invalid argument (invalid byte sequence)

## Disable the 'make test' that fails

    echo >>debian/rules
    echo "override_dh_auto_test:" >>debian/rules

## Remove all Debian package haskell depends (taken care of by cabal instead)

    sed '/\tlibghc/d' -i debian/control

## Build!

    debuild -us -uc -Igit

comment 2
@Alexander that DAV-0.4 problem is a bug in DAV, not git-annex. I've informed its author and it should be fixed soon, in a new version of DAV.
Comment by http://joeyh.name/ — Wed Oct 29 14:05:27 2025
can't install git-annex on OS X Mountain Lion without disabling WebDAV support

possibly related to this Debian issue:

trying to install git-annex with cabal on OS X 10.8.3, the build fails with

    Loading package DAV-0.4 ... linking ... ghc:
    lookupSymbol failed in relocateSection (relocate external)
    ~/.cabal/lib/DAV-0.4/ghc-7.4.2/HSDAV-0.4.o: unknown symbol `_DAVzm0zi4_PathszuDAV_version1_closure'
    ghc: unable to load package `DAV-0.4'
    Failed to install git-annex-4.20130417
    cabal: Error: some packages failed to install:
    git-annex-4.20130417 failed during the building phase. The exception was:
    ExitFailure 1

This was after following all of the instructions for the Homebrew install at http://git-annex.branchable.com/install/OSX/ I was able to work around this issue by installing with the WebDAV flag disabled (ie, added the option --flags="-WebDAV" to last command in the OS X install instructions):

    cabal install git-annex --bindir=$HOME/bin --flags="-WebDAV"

Comment by https://www.google.com/accounts/o8/id?id=AItOawkCw26IdxXXPBoLcZsQFslM67OJSJynb1w — Wed Oct 29 14:05:27 2025
Comments on this page are closed.