Why is latest version of cabal sometimes required to build?

I don’t really understand why this fails

cabal-3.8.1.0 repl -w ghc-9.8 --build-depends pretty-simple==4.0.0.0              

whereas these work successfully

cabal-3.8.1.0 repl -w ghc-9.8 --build-depends pretty-simple==4.0.0.0 --allow-newer
cabal-3.10.1.0 repl -w ghc-9.8 --build-depends pretty-simple==4.0.0.0

The operative part of the error message is below and it seems to be something to do with pretty-simple's Setup.hs. Does anyone understand why it would require cabal-3.10 when it builds under cabal-3.8 with --allow-newer? Does that mean that pretty-simple has a too-strict bound somewhere, or is there something more fundamental going on?


Resolving dependencies...
Error: cabal-3.8.1.0: Could not resolve dependencies:
[__0] trying: fake-package-0 (user goal)
[__1] next goal: pretty-simple (dependency of fake-package)
[__1] rejecting: pretty-simple-4.1.2.0 (conflict: fake-package =>
pretty-simple==4.0.0.0)
[__1] skipping: pretty-simple-4.1.1.0, pretty-simple-4.1.0.0 (has the same
characteristics that caused the previous version to fail: excluded by
constraint '==4.0.0.0' from 'fake-package')
[__1] trying: pretty-simple-4.0.0.0
[__2] next goal: pretty-simple:setup.Cabal (dependency of pretty-simple)
[__2] rejecting: pretty-simple:setup.Cabal-3.10.2.0/installed-544a,
pretty-simple:setup.Cabal-3.10.2.1, pretty-simple:setup.Cabal-3.10.2.0,
pretty-simple:setup.Cabal-3.10.1.0 (constraint from maximum version of Cabal
used by Setup.hs requires <3.10)
[__2] trying: pretty-simple:setup.Cabal-3.8.1.0
[__3] next goal: pretty-simple:setup.text (dependency of
pretty-simple:setup.Cabal)
[__3] rejecting: pretty-simple:setup.text-2.1/installed-0c74 (conflict:
pretty-simple:setup.Cabal => pretty-simple:setup.text>=1.2.3.0 && <1.3 ||
>=2.0 && <2.1)
[__3] skipping: pretty-simple:setup.text-2.1 (has the same characteristics
that caused the previous version to fail: excluded by constraint '>=1.2.3.0 &&
<1.3 || >=2.0 && <2.1' from 'pretty-simple:setup.Cabal')
[__3] trying: pretty-simple:setup.text-2.0.2
[__4] next goal: pretty-simple:setup.base (dependency of pretty-simple)
[__4] rejecting: pretty-simple:setup.base-4.19.0.0/installed-e327 (conflict:
pretty-simple:setup.text => pretty-simple:setup.ghc-prim>=0.2 && <0.11,
pretty-simple:setup.base =>
...
2 Likes

I think it’s because pretty-simple uses build-type: Custom. From this part of your error dump, I speculate that build-type: Custom makes cabal-install want to depend on cabal-the-library no newer than itself:

[__2] rejecting: pretty-simple:setup.Cabal-3.10.2.0/installed-544a,
pretty-simple:setup.Cabal-3.10.2.1, pretty-simple:setup.Cabal-3.10.2.0,
pretty-simple:setup.Cabal-3.10.1.0 (constraint from maximum version of Cabal
used by Setup.hs requires <3.10)

Then, it tries to solve the dependencies of that version of Cabal (the library). It looks like it can’t use newer versions of text because pretty-simple has an upper bound of <2.1, and it can’t use older versions because your GHC provides a too-new version of ghc-prim, and then the error dump stops and I can’t figure out any more.

Looking at hackage, it seems that cabal-doctest is actually deprecated. I’d probably (in increasing levels of effort):

  1. Try and get the maintainer of pretty-simple (or the Hackage Trustees) to raise some upper bounds so that you can find a build plan with older cabal-install.
  2. Get pretty-simple back onto build-type: Simple and ask people to doctest by running using --with-ghc=doctext.
  3. As №2, but create a test-suite target that is just a call to Test.DocTest.doctest. Whether this is practical is going to depend on how extensive the dependencies are, I suppose.
4 Likes

Yes, nice diagnosis @jackdk. This is a build-type: Custom problem, and the real long-term solution here is to move away from build-type: Custom as far as possible. Luckily at Well-Typed we managed to get some funding to do just that:

8 Likes

Thanks! There are certainly some mysterious things going on.

It’s the custom-setup that depends on Cabal and cabal-doctest. That seems pretty strange. Is it normal for custom setups to depend on Cabal? I could believe that. I don’t see why they should depend on a test framework though!

I guess it’s simple enough to work around, just by using cabal-3.10 but it seems rather fragile so it would be nice to do better if we can.

It looks like @george.fst is a maintainer. Maybe he can chime in?

Yes, we would really like to move away from the custom setup: see Cross-compilation broken by custom Setup.hs used for doctests · Issue #82 · cdepillabout/pretty-simple · GitHub. A pull request from anyone who knows the best way to run doctests these days would be greatly appreciated.

In the meantime, I can look at revising some bounds. Out of curiosity, why is it that you require version 4.0 of pretty-simple anyway?

1 Like

why is it that you require version 4.0 of pretty-simple anyway?

I don’t. 4.0.0.0 just happens to be the version for which I ran across the problem. The following fails too.

cabal-3.8.1.0 repl -w ghc-9.8 --build-depends 'pretty-simple>=4.1'
1 Like

Pier couldn’t handle custom setups. Unfortunate because as a build tool it was fast.

1 Like

I had a go and opened a PR. Let me know if this works for you.

3 Likes

I reported the "Cabal has too-strict bounds" part of this issue at Please relax bounds: older versions of Cabal don't build with newer dependencies · Issue #9616 · haskell/cabal · GitHub

2 Likes