Repository navigation
Description
This was discovered when using stack, the relevant issue is here: commercialhaskell/stack#3892. Copying the summary from there:
We have a project with package A that exposes a library and has a test module. Package B depends on A and exposes a library that is used by A's test suite (the reason for this is that package B is used by other packages). So there is a circularish dependency going on, which works when building with GHC 8.0.2 but not GHC 8.2.2. Not sure if this is stack or cabal or GHC or what, but I thought that stack has code to deal with this situation (checking whether it can do an all in one build, I think?), so perhaps something changed in GHC or cabal that stops it from working.
Steps to reproduce
Minimal example here: https://github.com/dten/CouldntMatchTypeRepro. Changing the resolver in the stack.yaml between LTS 9 and LTS 10 exhibits the change in behaviour.
After poking around it seems like stack's behaviour hasn't changed. I tried to replicate what stack does under the hood with cabal install 2.0.0.0 on that project. Using cabal install in the model dir, then cabal install in the testing dir, then cabal configure --enable-tests && cabal build in the model dir gives the same error as when using stack, as expected. I haven't used the new-* ommands much before, but making a basic cabal.project and trying cabal new-configure in the model directory reuslts in:
Warning: The package list for 'hackage.haskell.org' is 97 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
cabal.exe: Could not resolve dependencies:
trying: not-working-model-0.0.0 (user goal)
next goal: not-working-testing (user goal)
rejecting: not-working-testing-0.1.0.0 (cyclic dependencies; conflict set:
not-working-model, not-working-testing)
fail (backjumping, conflict set: not-working-model, not-working-testing)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: not-working-model, not-working-testing
(I changed the names because it looks like model is a package already on Hackage, so didn't want to confuse the matter). Is this a supported project configuration/workflow? Will it be in the future? It felt quite natural and useful to do at the time.
Activity
hvr commentedon Mar 9, 2018
related: #3422 & #1575
tswelsh commentedon Mar 10, 2018
Ah OK, this has been raised before. The fairly recent comment here #1575 (comment) says:
While using new-build failed as this comment suggests, it looks like the first part about installing things in order no longer works. Should this be considered a separate bug?
23Skidoo commentedon Jun 8, 2018
Closing in favour of #3422 and #1575. This use case is not yet supported by
new-build, but I believe that legacy-style sandboxes will still work.sebright commentedon Jun 11, 2018
I looked into the old-build part of this issue. I can reproduce the behavior change between cabal-install-1.24 and cabal-install-2.0 by running the following commands with GHC 8.0.2 and no package index:
cabal gives a warning when configuring
modelin both cases but continues:Then
cabal buildsucceeds with cabal from the 1.24 branch:The same command fails with cabal from the 2.0 branch:
The
modeltest suite references the library'sMyIdtype directly and through thetestingpackage'smakeIdfunction, in the functioniDontWork:I think that the cabal-install-2.0 error message means that the type of
makeIdfrom the installedmodeldoesn't match theMyIdtype from the sourcemodel. I don't think that is a bug, sincemodelcould be configured differently in the two commands. In fact, cabal-install-1.24 doesn't handle the project correctly either, because when I modifyTypes.Idsbetween installingmodeland building the tests, I get a link error (I also needed to add a reference to theNotWorkingmodule fromMain, becauseNotWorkingwas unused.):I think that the cyclic dependency in CouldntMatchTypeRepro is different from the most common use case in #1575, such as the
containersorbytestringtest suites, where the library's types aren't exposed through the API of the test helper. Packages likebytestringcould use an older version of the package to build the test framework while testing the source version of the library. To support building CouldntMatchTypeRepro in one command, we would need to build themodellibrary, buildtesting, and then build themodeltest suite.I also tested the use case where the library types don't need to match by building the
bytestringtest suite with cabal HEAD, and it still worked.