How to throw an error if using "cabal-install" < version XYZ?

Ryan Newton rrnewton at
Thu May 23 04:50:08 CEST 2013

A cabal-install bug <> was
fixed recently that pertains to building C libraries with profiling.

As a result, I want a certain
test if cabal-install < 0.17.0 is used, and throw a preemptive error.
 Otherwise this package fails in weird ways at runtime (it's a nasty one).

I noticed with some surprise the following sequence:

*   $ cabal --version*
*   cabal-install version*
*   using version of the Cabal library*
*   $ cabal clean*
*   $ cabal install*
*   $ cat dist/build/autogen/cabal_macros.h  | grep VERSION_Cabal*
*   #define VERSION_Cabal "1.17.0"*

Alright, so that, in retrospect, makes sense.  The version is which *my*
library is linked with is the relevant one, not the one cabal-install was
linked with [1].

So the natural next thought is to move the MIN_VERSION_Cabal test into
Setup.hs, and force cabal to use it by setting the build type to Custom.
 But... I just learned from this ticket that the cabal macros are not
available in Setup.hs:

Uh oh, what's left?


[1] P.S. Personally I'm now using a bash function like below, to force the
two versions to be the same:

function safe_cabal_install () {
  VER=`cabal --version | tail -n1 | awk '{ print $3 }'`
  cabal install --constraint="Cabal==$VER" $*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the cabal-devel mailing list