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

A cabal-install bug https://github.com/haskell/cabal/issues/1284 was fixed recently that pertains to building C libraries with profiling. As a result, I want a certain packagehttp://hackage.haskell.org/package/atomic-primops-0.1.0.2to 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 1.16.0.2* * using version 1.16.0.3 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: http://hackage.haskell.org/trac/hackage/ticket/326 Uh oh, what's left? -Ryan [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" $* }

Hey Ryan,
I ran into a related issue, heres a a way you can do this safe IN the cabal
file (or at least you can modify my hack for your purposes)
heres a link to the workaround I did for making LLVM-hs work across >= 1.17
and < 1.17 cabal, but you could abuse it to make sure setup.hs barfs on old
cabal https://github.com/bos/llvm/blob/master/base/Setup.hs#L89-L116
heres a quick one off gist that takes my trick and does something helpful
for you variant + makes sure the tool can't build otherwise
https://gist.github.com/cartazio/5632636
I just wrote a snippet that you can just add to your setup.hs and it should
guarantee the setup.hs will barf with a helpful error message on cabal <
1.17.0
On Wed, May 22, 2013 at 10:50 PM, Ryan Newton
A cabal-install bug https://github.com/haskell/cabal/issues/1284 was fixed recently that pertains to building C libraries with profiling.
As a result, I want a certain packagehttp://hackage.haskell.org/package/atomic-primops-0.1.0.2to 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 1.16.0.2* * using version 1.16.0.3 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:
http://hackage.haskell.org/trac/hackage/ticket/326
Uh oh, what's left?
-Ryan
[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" $* }
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Great! Thanks. I adapted that trick and it worked fine: https://github.com/rrnewton/haskell-lockfree-queue/blob/cb8ca1a5d8b4c02e45ee... On Wed, May 22, 2013 at 11:53 PM, Carter Schonwald < carter.schonwald@gmail.com> wrote:
Hey Ryan, I ran into a related issue, heres a a way you can do this safe IN the cabal file (or at least you can modify my hack for your purposes)
heres a link to the workaround I did for making LLVM-hs work across >= 1.17 and < 1.17 cabal, but you could abuse it to make sure setup.hs barfs on old cabal https://github.com/bos/llvm/blob/master/base/Setup.hs#L89-L116
heres a quick one off gist that takes my trick and does something helpful for you variant + makes sure the tool can't build otherwise
https://gist.github.com/cartazio/5632636
I just wrote a snippet that you can just add to your setup.hs and it should guarantee the setup.hs will barf with a helpful error message on cabal < 1.17.0
On Wed, May 22, 2013 at 10:50 PM, Ryan Newton
wrote: A cabal-install bug https://github.com/haskell/cabal/issues/1284 was fixed recently that pertains to building C libraries with profiling.
As a result, I want a certain packagehttp://hackage.haskell.org/package/atomic-primops-0.1.0.2to 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 1.16.0.2* * using version 1.16.0.3 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:
http://hackage.haskell.org/trac/hackage/ticket/326
Uh oh, what's left?
-Ryan
[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" $* }
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Perhaps I'm missing something, but why not just
cabal-version: >=1.18
?
It will constrain the Cabal version, not cabal-install, but judging from
the fix[1] this is what you actually need.
[1]: https://github.com/haskell/cabal/commit/d148336e97cda2e3585c453cf9af61bc3635...
Roman
* Ryan Newton
A cabal-install bug https://github.com/haskell/cabal/issues/1284 was fixed recently that pertains to building C libraries with profiling.
As a result, I want a certain packagehttp://hackage.haskell.org/package/atomic-primops-0.1.0.2to 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 1.16.0.2* * using version 1.16.0.3 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:
http://hackage.haskell.org/trac/hackage/ticket/326
Uh oh, what's left?
-Ryan
[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" $* }
_______________________________________________ cabal-devel mailing list cabal-devel@haskell.org http://www.haskell.org/mailman/listinfo/cabal-devel

constraining it to >= 1.17 would be better while 1.18 isn't out yet..
On Thu, May 23, 2013 at 1:42 AM, Roman Cheplyaka
Perhaps I'm missing something, but why not just
cabal-version: >=1.18
?
It will constrain the Cabal version, not cabal-install, but judging from the fix[1] this is what you actually need.
[1]: https://github.com/haskell/cabal/commit/d148336e97cda2e3585c453cf9af61bc3635...
Roman
A cabal-install bug https://github.com/haskell/cabal/issues/1284 was fixed recently that pertains to building C libraries with profiling.
As a result, I want a certain packagehttp://hackage.haskell.org/package/atomic-primops-0.1.0.2to 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 1.16.0.2* * using version 1.16.0.3 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:
http://hackage.haskell.org/trac/hackage/ticket/326
Uh oh, what's left?
-Ryan
[1] P.S. Personally I'm now using a bash function like below, to force
* Ryan Newton
[2013-05-22 22:50:08-0400] the two versions to be the same:
function safe_cabal_install () { VER=`cabal --version | tail -n1 | awk '{ print $3 }'` cabal install --constraint="Cabal==$VER" $* }
_______________________________________________ cabal-devel mailing list cabal-devel@haskell.org http://www.haskell.org/mailman/listinfo/cabal-devel
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Carter Schonwald
-
Roman Cheplyaka
-
Ryan Newton