ekmett / parsers

Generic parser combinators
Other
88 stars 38 forks source link

Building tests via cabal fails when adding dependencies hspec and trifecta #73

Closed freeman42x closed 6 years ago

freeman42x commented 6 years ago

To reproduce:

checkout unexpected-bug-example branch from this fork: https://github.com/razvan-panda/parsers/tree/unexpected-bug-example

cabal sandbox init
cabal install --only-dependencies --enable-tests

Resolving dependencies...
cabal: Could not resolve dependencies:
next goal: trifecta (dependency of parsers-0.12.8:*test)
rejecting: trifecta-1.7.1.1/installed-A22... (package is broken)
rejecting: trifecta-1.7.1.1, trifecta-1.7.1, trifecta-1.7, trifecta-1.6.2.1,
trifecta-1.6.2, trifecta-1.6.1 (cyclic dependencies; conflict set: parsers,
trifecta)
rejecting: trifecta-1.6 (conflict: base==4.10.1.0/installed-4.1..., trifecta
=> base>=4.4 && <4.9.1)
rejecting: trifecta-1.5.2, trifecta-1.5.1.3, trifecta-1.5.1.2,
trifecta-1.5.1.1, trifecta-1.5.1, trifecta-1.5, trifecta-1.4.3,
trifecta-1.4.2, trifecta-1.4.1 (cyclic dependencies; conflict set: parsers,
trifecta)
rejecting: trifecta-1.4 (conflict: base==4.10.1.0/installed-4.1..., trifecta
=> base>=4.4 && <4.7)
rejecting: trifecta-1.2.1.1, trifecta-1.2.1 (cyclic dependencies; conflict
set: parsers, trifecta)
rejecting: trifecta-1.2 (conflict: base==4.10.1.0/installed-4.1..., trifecta
=> base<0)
rejecting: trifecta-1.1, trifecta-1.0 (cyclic dependencies; conflict set:
parsers, trifecta)
trying: trifecta-0.53
trying: template-haskell-2.12.0.0/installed-2.1... (dependency of
tagged-0.8.5)
next goal: pretty (dependency of template-haskell-2.12.0.0/installed-2.1...)
rejecting: pretty-1.1.3.3/installed-1.1... (conflict: pretty =>
deepseq==1.4.3.0/installed-1.4..., trifecta => deepseq>=1.2.0.1 && <1.4)
rejecting: pretty-1.1.3.6, pretty-1.1.3.5, pretty-1.1.3.4, pretty-1.1.3.3,
pretty-1.1.3.2, pretty-1.1.3.1, pretty-1.1.2.1, pretty-1.1.2.0,
pretty-1.1.1.3, pretty-1.1.1.2, pretty-1.1.1.1, pretty-1.1.1.0,
pretty-1.1.0.0, pretty-1.0.1.2, pretty-1.0.1.1, pretty-1.0.1.0, pretty-1.0.0.0
(conflict: template-haskell => pretty==1.1.3.3/installed-1.1...)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: terminfo, trifecta, base, parsers,
parsers-0.12.8:test
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.

Building using stack test works fine.

phadej commented 6 years ago

trifecta depends on parsers, so currently that kind of setup doesn't work.

rejecting: trifecta-1.7.1.1, trifecta-1.7.1, trifecta-1.7, trifecta-1.6.2.1,
trifecta-1.6.2, trifecta-1.6.1 (cyclic dependencies; conflict set: parsers,
trifecta)

With sandboxes you could cabal install, cabal install trifecta, and then reconfigure parsers with --enable-tests. That what stack does under the hood.

freeman42x commented 6 years ago

@phadej I did something like that earlier - since it mentioned the package was broken - with --force-reinstalls and then everything built.

Isn't there any way to get cabal to reliably run the tests on cabal test? Does it have to be done manually like this?

RyanGlScott commented 6 years ago

Let me ask this: why are you trying to put a downstream dependency of trifecta directly into parsers' test suite? Due to https://github.com/haskell/cabal/issues/1575, that's just asking for trouble.

As @phadej notes in https://github.com/ekmett/parsers/issues/73#issuecomment-378393573, you can sometimes make this work by manually installing the dependencies before configuring your project. But even then it's not always guaranteed to work, as #72 (and https://github.com/bos/vector-binary-instances/pull/8) demonstrate. Cyclic dependencies is simply not a tenable approach at the moment.

I don't know what your intentions are with this project, but my recommendation is to separate the test suite into a separate .cabal file, like what was done in https://github.com/ekmett/transformers-compat/pull/33 and https://github.com/haskell/primitive/pull/90, and have a single cabal.project/stack.yaml file that includes both parsers.cabal and parsers-tests.cabal as projects. That way, you'll be able to build trifecta on top of your local copy of parsers, and you won't run into cyclic dependencies.

In any case, this is not a bug with parsers itself, so closing.

freeman42x commented 6 years ago

@RyanGlScott My intention with the project was to provide some tests/examples for using parsers, and those tests depended on trifecta also. It is unfortunate that in this scenario tests do not work with cabal but work fine with stack.