(Imported from Trac #945, reported by @tibbe on 2012-04-24)
The containers package has a test-suite section which seems to create a cycle when building the package. Could it be that Cabal treats the package as one unit instead of treating the library and test-suite sections separately, which should remove the cycle.
$ cabal install --enable-tests -v3
searching for ghc in path.
found ghc at /usr/local/bin/ghc
/usr/local/bin/ghc is version 7.4.1
looking for tool "ghc-pkg" near compiler in /usr/local/bin
found ghc-pkg in /usr/local/bin/ghc-pkg
/usr/local/bin/ghc-pkg is version 7.4.1
Reading installed packages...
Reading available packages...
Choosing modular solver.
[__0] trying: containers-0.5.0.0 (user goal)
[__1] next goal: base (dependency of containers-0.5.0.0)
[__1] rejecting: base-18.104.22.168, 22.214.171.124 (global constraint requires installed instance)
[__1] trying: base-126.96.36.199/installed-f76...
[__2] trying: rts-1.0/installedbuil... (dependency of base-188.8.131.52/installed-f76...)
[__3] trying: integer-gmp-0.4.0.0/installed-ec8... (dependency of base-184.108.40.206/installed-f76...)
[__4] rejecting: containers-0.5.0.0:!test (global constraint requires opposite flag selection)
[__4] trying: containers-0.5.0.0:*test
[__5] trying: test-framework-quickcheck2-0.2.12.1 (dependency of containers-0.5.0.0:*test)
[__6] trying: test-framework-quickcheck2-0.2.12.1:+base4
[__7] trying: test-framework-quickcheck2-0.2.12.1:-base3
[__8] trying: random-220.127.116.11/installed-3be... (dependency of test-framework-quickcheck2-0.2.12.1:+base4)
[__9] trying: time-1.4/installed-3e1... (dependency of random-18.104.22.168/installed-3be...)
[_10] trying: old-locale-22.214.171.124/installed-29b... (dependency of time-1.4/installed-3e1...)
[_11] trying: extensible-exceptions-0.1.1.4/installed-d27... (dependency of test-framework-quickcheck2-0.2.12.1)
[_12] trying: test-framework-hunit-0.2.7 (dependency of containers-0.5.0.0:*test)
[_13] trying: test-framework-hunit-0.2.7:+base4
[_14] trying: test-framework-hunit-0.2.7:-base3
[_15] trying: test-framework-0.6 (dependency of containers-0.5.0.0:*test)
[_16] trying: test-framework-0.6:-tests
[_17] trying: test-framework-0.6:+splitbase
[_18] trying: hostname-1.0 (dependency of test-framework-0.6)
[_19] trying: xml-1.3.12 (dependency of test-framework-0.6)
[_20] trying: text-0.11.2.0/installed-a62... (dependency of xml-1.3.12)
[_21] trying: bytestring-0.9.2.1/installed-4ad... (dependency of xml-1.3.12)
[_22] trying: regex-posix-0.95.1 (dependency of test-framework-0.6)
[_23] trying: regex-posix-0.95.1:+splitbase
[_24] trying: regex-posix-0.95.1:+newbase
[_25] trying: regex-base-0.93.2 (dependency of regex-posix-0.95.1:+newbase)
[_26] trying: regex-base-0.93.2:+splitbase
[_27] trying: regex-base-0.93.2:+newbase
[_28] trying: mtl-2.1/installed-0a8... (dependency of regex-base-0.93.2:+newbase)
[_29] trying: transformers-0.3.0.0/installed-f23... (dependency of mtl-2.1/installed-0a8...)
[_30] trying: ansi-wl-pprint-0.6.4 (dependency of test-framework-0.6)
[_31] trying: ansi-wl-pprint-0.6.4:+newbase
[_32] trying: ansi-wl-pprint-0.6.4:-example
[_33] trying: ansi-terminal-0.5.5 (dependency of test-framework-0.6)
[_34] trying: ansi-terminal-0.5.5:+splitbase
[_35] trying: ansi-terminal-0.5.5:-example
[_36] trying: unix-126.96.36.199/installed-346... (dependency of ansi-terminal-0.5.5)
[_37] trying: QuickCheck-2.4.2 (dependency of containers-0.5.0.0:*test)
[_38] trying: QuickCheck-2.4.2:+templatehaskell
[_39] trying: QuickCheck-2.4.2:+base4
[_40] trying: QuickCheck-2.4.2:+base3
[_41] next goal: template-haskell (dependency of QuickCheck-2.4.2:+templatehaskell)
[_41] rejecting: template-haskell-188.8.131.52/installed-164... (conflict: containers==0.5.0.0, template-haskell => containers==0.4.2.1/installed-7c5...)
[_41] trying: template-haskell-184.108.40.206
[_42] trying: pretty-220.127.116.11/installed-7e1... (dependency of template-haskell-18.104.22.168)
[_43] trying: HUnit-22.214.171.124 (dependency of containers-0.5.0.0:*test)
[_44] trying: HUnit-126.96.36.199:+base4
[_45] trying: ghc-prim-0.2.0.0/installed-bd2... (dependency of containers-0.5.0.0)
[_46] trying: deepseq-188.8.131.52/installed-6c1... (dependency of containers-0.5.0.0)
[_47] next goal: array (dependency of containers-0.5.0.0)
[_47] trying: array-0.4.0.0/installed-0b3...
cabal: internal error: could not construct a valid install plan.
The proposed (invalid) plan contained the following problems:
The following packages are involved in a dependency cycle test-framework-hunit-0.2.7, test-framework-0.6, regex-posix-0.95.1, regex-base-0.93.2, containers-0.5.0.0, test-framework-quickcheck2-0.2.12.1, QuickCheck-2.4.2, template-haskell-184.108.40.206
(Imported comment by @kosmikus on 2012-04-24)
Ok, I can confirm the problem by using the Github version of containers on a plain ghc-7.4.1 installation.
The problem is actually not a solver problem, as I first thought, but a more fundamental problem in Cabal. It's also independent of using the modular solver.
So the problem here is that the testsuite of containers indirectly depends on containers again. The question is whether this should be allowed.
Fixing this would indeed mean that we should be able to build containers first, then the dependencies of the test framework, and finally the testsuite. We'd indeed have to introduce a possibility to build flavours or parts of packages in isolation. It'd for example be nice to be able to separately build non-profiling and profiling versions of a lib.
However, I'm afraid this change will take some more careful design, so don't expect a quick fix.
(Imported comment by @tibbe on 2012-04-24)
When I think about it I believe I've seen this problem before, with benchmarks. I generally hack on lower-level libraries and my test and benchmark dependencies indirectly depend on the library I'm working on quite often nowadays (e.g. Criterion depends on unordered-containers and I use Criterion to benchmark unordered-containers.)
A workaround for the low-level libraries might be to manually split into containers and containers-tests.
Splitting is kind of a pain, although it does work.
See also #960 and PR #3422
I'm closing this in favor of #1575, which has more discussion.