Repository navigation
Description
Update by @ezyang: See @edsko's comment at #1575 (comment) we don't actually want to dep solver for each package individually, according to @dcoutts.
Update by @dcoutts: the latest iteration of idea 1 below is as follows:
Suppose for sake of argument we're looking at bytestring which has a test suite that uses tasty, and tasty depends indirectly on bytestring. So the original proposal was to resolve this cycle by building the under-development bytestring and then building tasty against that, and then building the bytestring testsuite against the freshly built tasty package. But actually this is crazy, it means every time I make a small edit to bytestring and want to re-run the tests, cabal has to go and rebuild tasty (and all the other deps of tasty that use bytestring). This would get really annoying really quickly. Also, we don't really want to build tasty against an in-development version of bytestring, we want tasty to use a stable version of bytestring. So much better is to have tasty be built using an existing stable bytestring. Then tasty etc does not need to be rebuilt as we make minor changes to the in-development version of bytestring.
So this requires we have a solution using two different version of bytestring. We already have something like this for dependencies of Setup scripts, which we call "independent" dependencies. So we can treat the dependencies of the test-suite /which it doesn't share with the library/ as independent. See #3422 for a partial implementation of this idea and a discussion of the difficulties.
Idea 2 below would require a different approach. In general it is important to have consistent behaviour of code in one component (e.g. exe) vs another component in the same package. This is what authors generally expect. This means that two exes both use some lib then they need to use the same version of that lib. If authors really want to allow two exes in the same package to use different versions of some dep then this ought to be explicit and we should come up with some mechanism to do so. If we go down this route then we should also consider the case of the same component using two different version of a lib. We might handle that like package qualified module imports, giving each one a different local name. This also relates to backpack.
I think we should create the install plan on a component (i.e. library, executable, test-suite, and benchmark) basis instead of creating one for the whole package.
There are two use cases I can think of:
- There's a growing number of packages (anything that's a dependency of either test-frame-work and its related packages or of criterion) that can't have test suite or benchmark sections, as that would create a dependency cycle.
- Users have requested being able to build executables (in a single package) that have conflicting dependencies.
I suggest that we treat each component as if it was a "package" with name package-x.y.z.w:component-name, for the purpose of dependency resolution.
Activity
23Skidoo commentedon Nov 11, 2013
+1, this would be nice to have.
ygale commentedon Nov 28, 2013
#1532 might be another reason this would be a good idea.
kosmikus commentedon Nov 28, 2013
I don't think that the solver-part would be really hard. But we need to be able to build and install the components separately, otherwise this is worthless.
23Skidoo commentedon Nov 29, 2013
With 1.18, we have this for
build. I think that we don't need per-component install. The use cases Johan mentions don't actually require splitting packages other than the install target (one can only depend on libraries anyway, and there's guaranteed to be only a single library per package). We only need a way to selectively enable components withconfigure; for tests and benchmarks we already have that with--enable-testsand--enable-benchmarks.So it looks to me that both use cases can be supported with no changes to the solver, only by splitting the install target into several virtual packages. Example of the first use case:
For building a subset of exes something like
configure --enable-component=foo,bar,bazwill have to be added. Again, this will be needed only for the current target. Not sure if we want to allow installing such partially-configured packages withcabal install.ygale commentedon Nov 29, 2013
In #1541 you have a use case with two targets, A and B, with A an executable used as a preprocessor for the source code of library or executable B. A must be built and installed (or at least made accessible at some predictable path) before B is built.
23Skidoo commentedon Nov 29, 2013
@ygale
In #1541, all you want is to build A before B (A and B don't have conflicting dependencies). This should be possible to fix on the component graph level (since they are both a part of the same package), once there's a way to declare that B depends on A.
#1532 seems to be unrelated.
ygale commentedon Nov 29, 2013
Yes, you are correct that in our case it happens that there are no conflicting dependencies. But that is certainly possible. So this is another use case.
Also, here you need access to the compiled executable for A before beginning to build B, so there needs to be some kind of "install" step for A before B is built. It doesn't necessarily need to be the same thing as
cabal install, but the salted dist directory is not suitable.23Skidoo commentedon Nov 29, 2013
A only needs to be in PATH. I believe that this works now since you said that that worked with 1.16.
23Skidoo commentedon Apr 16, 2015
Related: @edsko's work on independent goals (#2531, #2530, #2515, #2514, etc.) and this comment by @kosmikus.
edsko commentedon Apr 16, 2015
With my work on fine grained dependencies in the solver, the solver part of this should be relatively easy. The harder part would be to change the way the installer works.
edsko commentedon Apr 16, 2015
Incidentally, the testsuite use case mentioned by @tibbe can be addressed in a simpler, if not quite as general way: we can treat the dependencies of the test-suite which it doesn't share with the library as independent. This would make it possible to have, say, a
tastytestsuite foroptparse-applicativeeven thoughtastydepends onoptparse-applicative.Without changing anything else, this would mean we can then link
tastyto an another (probably older) version ofoptparse-applicativethan the one we are testing. (It would require theoptparse-applicativetest suite to use thesrc/dir of its main library directly, rather than have an internal dependency on theoptparse-applicativelibrary).This is something I've previously discussed with @dcoutts and it should be quite easy to do know do (I'm not sure I'll have time left to do it though).
BardurArantsson commentedon Jun 25, 2015
@edsko Please do what it is you do. From my experience the major irritation here is the test-suite case.
26 remaining items
sebright commentedon Nov 5, 2016
Issues describing specific examples of cyclic dependencies caused by test suites:
#935 - containers
#960 - text
#3824 - bytestring
phadej commentedon Jun 26, 2017
BTW already in #3824 was mentioned that it's a blocker for 2.0;
yet if 3.0 if the milestone where
new-buildis the only thing, that's a hard deadline.Today while going through some packages, few other occurrences:
unordered-containers: cannot build benchmarks (criterionin the loop)aesonhas a workaround: benchmarks pulled into separate packageinteger-logarithmscannot build test-suite (quickcheck-instances->scientific)scientifichas benchmark suiteThis is a real blocker to develop core packages using
new-build.To return comment to the starting post:
I'd prefer to rebuild the
tastyeach time. Because currently in some packages' Travis scripts we docabal install --disable-tests --disable-benchmarks cabal install test-framework criterion ... cabal configure --enable-tests --enable-benchmarks cabal testE.g.
hashable: https://github.com/tibbe/hashable/blob/339ae0ad3250c4d6b703e2fc781ce81a190c8d23/.travis.yml#L121That workaround is impossible with
new-build.Fancier solution using multiple package versions would be cool, but this issue have been open for almost 4 years. I don't need the perfect solution, I'm quite ok with some solution.
sebright commentedon Jun 27, 2017
That makes sense. The only downside I can think of is that projects might start relying on cyclic dependencies between packages, and then it might be harder to switch to the more limited, two-version solution later.
phadej commentedon Jun 27, 2017
@GrayJay I'm not sure I personally even want two version solution. All the cases mentioned in your #1575 (comment) and my #1575 (comment) are "core" packages, which are (possibly transitive) dependencies of
criterion,tastyortest-framework.It would be completely OK for me to explicitly toggle the switch to allow such "loop" (no name idea atm, but some flag to
new-build)chris-martin commentedon Oct 19, 2017
Sorry I'm about to ask some dumb question here, but I've been reading a lot of discussion on this issue dating back many years, and -- I'm very confused about the state of this bug, so I'm just hoping to understand where we are with it, to figure out whether there's hope of ever testing my projects with Cabal.
foo:test->bar:lib->foo:lib(with dependency relationships indicated by the arrows), Cabal will always fail to build this project?sebright commentedon Oct 22, 2017
cabal can't build the tests in one step, but it is possible to install foo, install bar, and then build foo with tests enabled.
cabal new-buildcan't build the tests, though, because it can't install packages in one step and then use the installed packages as inputs when calculating the next install plan.Yes, though there are two possible solutions. #4087 would allow install plans to have cycles between packages, but no cycles between components. #3422 would allow install plans to use two versions of the library to break a cycle when building test suites and benchmarks.
I think that stack builds the packages in multiple steps.
re-enable nofib test suite
sebright commentedon Jun 11, 2018
See #5200 for an example of a project where cabal would need to use consistent versions for the library used by the test suite helper and the library under test.
sebright commentedon Oct 29, 2018
See #5645 for more discussion of this issue.
Put Arbitrary instances for Cabal types in their own package.
Put Arbitrary instances for Cabal types in their own package.
Put Arbitrary instances for Cabal types in their own package.
parsonsmatt commentedon Apr 6, 2019
This issue is blocking the use of
cabal new-*on thepersistentrepository.hvr commentedon Apr 7, 2019
Not for me and I wasn't able to confirm your claim. I performed the following steps:
So for me the lack of a
cabal.project-equivalent to thestack.yamlfile combined with the gratuitous use ofhpackin one of the 9 local packages was blocking the use ofcabal new-buildwith persistent's repo to be working out of the box; but other than the use of non-standard file formats I didn't notice any problems.parsonsmatt commentedon Apr 8, 2019
@hvr The issue is occurring in this branch which introduces a pseudocircular dependency. The failure occurred after writing an appropriate
cabal.projectfile and usinghpackto generate thecabalfile.