haskell-hvr / cassava

A CSV parsing and encoding library optimized for ease of use and high performance
http://hackage.haskell.org/package/cassava
BSD 3-Clause "New" or "Revised" License
223 stars 107 forks source link

error **INVARIANT BROKEN** Detected invalid combination of `text-short` and `bytestring` versions. Please verify the `pre-bytestring-0.10-4` flag-logic in the .cabal file wasn't elided. #154

Closed RyanGlScott closed 7 years ago

RyanGlScott commented 7 years ago

I recently ran into this issue when installing some packages with --allow-newer. One can reproduce the issue by installing cassava-0.5.1.0 by itself with --allow-newer (I'm using cabal-install-2.0.0.0, if that makes a difference):

$ cabal install cassava --allow-newer
Resolving dependencies...
Configuring cassava-0.5.1.0...
Building cassava-0.5.1.0...
Failed to install cassava-0.5.1.0
Build log ( /u/rgscott/.cabal/logs/ghc-8.2.1/cassava-0.5.1.0-6OWXHnNDaQwGfhEhSLNfq5.log ):
cabal: Entering directory '/tmp/cabal-tmp-444/cassava-0.5.1.0'
Configuring cassava-0.5.1.0...
Preprocessing library for cassava-0.5.1.0..
Building library for cassava-0.5.1.0..

Data/Csv/Conversion.hs:26:3: error:
     error: #error **INVARIANT BROKEN** Detected invalid combination of `text-short` and `bytestring` versions. Please verify the `pre-bytestring-0.10-4` flag-logic in the .cabal file wasn't elided.
     # error **INVARIANT BROKEN** Detected invalid combination of `text-short` and `bytestring` versions. Please verify the `pre-bytestring-0.10-4` flag-logic in the .cabal file wasn't elided.
       ^
   |
26 | # error **INVARIANT BROKEN** Detected invalid combination of `text-short` and `bytestring` versions. Please verify the `pre-bytestring-0.10-4` flag-logic in the .cabal file wasn't elided.
   |   ^

Data/Csv/Conversion.hs:99:0: error:
     warning: "MIN_VERSION_text_short" is not defined [-Wundef]
     #if MIN_VERSION_text_short(0,1,0)
     ^
   |
99 | #if MIN_VERSION_text_short(0,1,0)
   | ^

Data/Csv/Conversion.hs:99:0: error:
     error: missing binary operator before token "("
   |
99 | #if MIN_VERSION_text_short(0,1,0)
   | ^

Data/Csv/Conversion.hs:1010:0: error:
     warning: "MIN_VERSION_text_short" is not defined [-Wundef]
     #if MIN_VERSION_text_short(0,1,0)
     ^
     |
1010 | #if MIN_VERSION_text_short(0,1,0)
     | ^

Data/Csv/Conversion.hs:1010:0: error:
     error: missing binary operator before token "("
     |
1010 | #if MIN_VERSION_text_short(0,1,0)
     | ^
`gcc' failed in phase `C pre-processor'. (Exit code: 1)
cabal: Leaving directory '/tmp/cabal-tmp-444/cassava-0.5.1.0'
cabal: Error: some packages failed to install:
cassava-0.5.1.0-6OWXHnNDaQwGfhEhSLNfq5 failed during the building phase. The
exception was:
ExitFailure 1
hvr commented 7 years ago

@RyanGlScott This isn't actually a bug... that's the very reason I placed that CPP assertion in there ;-)

Fwiw, the unqualified --allow-newer sledge-hammer is going to get deprecated or at least emit a big fat warning in future cabals. I've recently invested some time to significantly extend --allow-{older,newer} capabilities to allow for fine-grained control, see http://cabal.readthedocs.io/en/latest/nix-local-build.html#cfg-field-allow-newer for current state. Specifically, --allow-newer: ^* will be a safer way to relax "all" upper bounds. TLDR: don't use an unqualified --allow-newer, it's almost always not what you want.

RyanGlScott commented 7 years ago

I'm still confused as to what exactly the problem would be with building cassava with the most recent versions of all dependencies.

hvr commented 7 years ago

@RyanGlScott the problem is that you end up with a configuration which lacks class instances as the flag logic in the .cabal file which is considered as invariant wouldn't hold up anymore; this is because ignoring all upper bounds also removes bounds whose function is rather as predicates for the conditionals than dependency bounds. However, with the introduction of ^>=-style bounds, we finally have a way to distinguish between hard (which you don't want to relax in general) and soft bounds (which can be relaxed with less problems) in a more natural way.

RyanGlScott commented 7 years ago

That makes sense. Thanks!