You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't build with --enable-tests in presence of circular dependencies #960
Update by @ezyang: when per-component build merges #3662 the builder bits are all done; all we need to do is teach the solver how to make test suite deps private, and then propagate that through the nix-local-build code.
The text library has a tests stanza that I can't use because I get an error of this form:
Preprocessing test suite 'tests' for text-0.11.2.2...
<command line>: cannot satisfy -package-id text-0.11.2.2-inplace:
text-0.11.2.2-inplace is shadowed by package text-0.11.2.2-fa0303a547febb0fcc06906255b11d31
I believe the problem is caused by the fact that a library that text's tests depend on uses text itself.
I realise that this is likely to be difficult to fix, but it's a problem for "core" libraries: @tibbe reports that containers faces the same difficulty.
I can certainly see that this is a problem, but does anyone have any reasonable suggestions for a fix? I mean, if you have cyclical dependencies that's (in itself) a huge problem for the integrity of your tests. Should cabal(-install) try to achieve some sort of fixed-point, or what?
AFAICT this is generally an issue of a "lack of Backpack", i.e. there are really no library "interfaces" -- only implementations. As such I don't see how this can actually be (even theoretically) be solved given the current state of GHC/Cabal.
Unless we get Backpack (or similar API separation) I don't see any other real solution other than breaking apart libraries appropriately such that types and instances are separate from implementation. (But even that may not be enough.)
My pronouncement would therefore be: "Break the dependency, libraries!" (I know it's not necessarily simple.)
EDIT: ... and that this isn't something that Cabal/cabal-install can (even theoretically) solve. Thus it should be closed.
@BardurArantsson The solution to this is actually very simple to state: "sandboxes always". Rather than installing the library-to-be-tested into the in-place package database, it should be installed into a sandbox. Then, its test dependencies can be installed into the sandbox. Finally, the tests can be built and run using the sandbox version of the library. This would be intellectually simple to do, but there's just a lot of things that need to be moved about to do it.
Ok... let's see it! What things need to be moved about and how would you do it? :)
I understand that if the circularity is only because test-X-depends-on-impl-Y-which-depends-on-tests-for-X, it should be easy do to a sort of "tiered" compilation where the two impls are compiled first (without testing) and then tests are run afterwards. However, I didn't get the impression that that was the case from the discussion. My bad, if that was wrong. Especially since there should be no way for an impl-of-X to depend on Y-and-test-of-Y, only Y. If it's just a matter of not running tests in some circumstances, then I'm with you.
I still maintain that you should "just" separate your tests into a separate project in that case.
Ok... let's see it! What things need to be moved about and how would you do it? :)
Split the configure phase apart so each component can be configured separately. This will be where things are moved around, but I can't go into more detail without going and doing it.
Configure tests to build against the in-place package database by default (in Cabal).
Have cabal-install configure tests to build against the sandbox, rather than the in-place package database.
I still maintain that you should "just" separate your tests into a separate project in that case.
Cabal doesn't support tests-only packages, and cabal-install doesn't (yet) have features for working with multiple packages simultaneously. There are open tickets for both of these features.
When per-component build merges #3662 the builder bits are all done; all we need to do is teach the solver how to make test suite deps private, and then propagate that through the nix-local-build code.
Activity
bos commentedon Jul 4, 2012
You can see another instance of this bug in mwc-random issue 15.
kosmikus commentedon Jul 10, 2012
Yes, see #935 for the
containersproblem.kolmodin commentedon Jan 2, 2014
The
binarylibrary faces the same problem.BardurArantsson commentedon Jun 25, 2015
I can certainly see that this is a problem, but does anyone have any reasonable suggestions for a fix? I mean, if you have cyclical dependencies that's (in itself) a huge problem for the integrity of your tests. Should cabal(-install) try to achieve some sort of fixed-point, or what?
AFAICT this is generally an issue of a "lack of Backpack", i.e. there are really no library "interfaces" -- only implementations. As such I don't see how this can actually be (even theoretically) be solved given the current state of GHC/Cabal.
Unless we get Backpack (or similar API separation) I don't see any other real solution other than breaking apart libraries appropriately such that types and instances are separate from implementation. (But even that may not be enough.)
My pronouncement would therefore be: "Break the dependency, libraries!" (I know it's not necessarily simple.)
EDIT: ... and that this isn't something that Cabal/cabal-install can (even theoretically) solve. Thus it should be closed.
ttuegel commentedon Jun 25, 2015
@BardurArantsson The solution to this is actually very simple to state: "sandboxes always". Rather than installing the library-to-be-tested into the in-place package database, it should be installed into a sandbox. Then, its test dependencies can be installed into the sandbox. Finally, the tests can be built and run using the sandbox version of the library. This would be intellectually simple to do, but there's just a lot of things that need to be moved about to do it.
BardurArantsson commentedon Jun 25, 2015
Ok... let's see it! What things need to be moved about and how would you do it? :)
I understand that if the circularity is only because test-X-depends-on-impl-Y-which-depends-on-tests-for-X, it should be easy do to a sort of "tiered" compilation where the two impls are compiled first (without testing) and then tests are run afterwards. However, I didn't get the impression that that was the case from the discussion. My bad, if that was wrong. Especially since there should be no way for an impl-of-X to depend on Y-and-test-of-Y, only Y. If it's just a matter of not running tests in some circumstances, then I'm with you.
I still maintain that you should "just" separate your tests into a separate project in that case.
ttuegel commentedon Jun 26, 2015
Cabal doesn't support tests-only packages, and cabal-install doesn't (yet) have features for working with multiple packages simultaneously. There are open tickets for both of these features.
dcoutts commentedon Jul 6, 2015
We think we've got a solution to this, see the last section of http://www.well-typed.com/blog/2015/07/cabal-setup-deps/
This would also lets us get rid of the fallback for when configure fails to find a solution.
tibbe commentedon Jul 7, 2015
Anyone willing to implement?
3 remaining items
dcoutts commentedon Jun 13, 2016
See also PR #3422
ezyang commentedon Aug 16, 2016
When per-component build merges #3662 the builder bits are all done; all we need to do is teach the solver how to make test suite deps private, and then propagate that through the nix-local-build code.
sebright commentedon Nov 5, 2016
I'm closing this in favor of #1575, which has more discussion.