Description
Describe the bug
Suppose I have a local package B
which provides a build tool, and which either has tests or depends on a package A
that has tests. Finally, I have another local package C
which depends on B
's build tool.
Finally, I have tests: true
in my cabal.project
, since I naturally want to test my local packages.
The result of this is that the solver becomes slower, because (I hypothesize) it tries to create a build plan for A
without tests to satisfy the build-tool dependency, then finds that it can't do that (due to the project constraint) and has to redo it.
That looks something like this (from cabal configure -v3
):
[_13] trying: C:B:exe.A~>A-0.1.0.0 (dependency of C:B:exe.B)
[_14] rejecting: C:B:exe.A:!test (dependencies not linked: stanza "test" incompatible; conflict set: A, B, C:B:exe.A, C:B:exe.B, A:test, C:B:exe.A:test)
This is not a big deal in a small project. However, if we have a long chain of packages up to the build tool dependency like so:
A->B-> ... ->Z->Tool
all of which with tests, then the solver will redo most of the work over and over until it finally realises it has to build all of A
to Z
with tests. This can cause a very large slowdown in solving time.
cabal freeze
does not help, since it only pins the versions and the test/no-test incompatibility still bites.
To Reproduce
I made a repository that exhibits the behaviour I described in the small: https://github.com/michaelpj/cabal-build-tool-depends-solver-repro
Changing tests:true
to tests:false
in cabal.project
stops the solver from failing and having to backtrack.
Expected behavior
I don't understand how cabal's solver works at all, but I would like this to not be slow! Maybe the test/no-tests constraint needs to be pushed down eagerly?
System information
- NixOS
- cabal 3.4.0.0, ghc 8.10.4