Skip to content

Error without any exceptions #4365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
boris-stepanov opened this issue Oct 19, 2018 · 10 comments
Closed

Error without any exceptions #4365

boris-stepanov opened this issue Oct 19, 2018 · 10 comments

Comments

@boris-stepanov
Copy link

boris-stepanov commented Oct 19, 2018

General summary/comments

Stack doesn't properly resolve dependencies between libraries and test-suites. I found it while refactoring my own code, so it's a real world scenario. Solution it to add "L1" as a dependency for "E1" test-suite.

Steps to reproduce

  1. Create 3 projects: L1, L2, E1.
  2. Create stack.yaml:
resolver: lts-11.22
packages:
    - L1
    - L2
    - E1
  1. Create L1/L2/E1 cabal files: (minimum configuration is here)
name:                  L1
version:               1.0

library

Test-Suite tests
  type:                exitcode-stdio-1.0
  main-is:             Test.hs
  build-depends:       L2 -any
name:                  L2
version:               1.0

library
  build-depends:       L1 -any
name:                  E1
version:               1.0

Test-Suite tests
  type:                exitcode-stdio-1.0
  main-is:             Test.hs
  build-depends:       L2 -any
  1. Run stack test

Expected

Stack throws somewhat like Dependency cycle detected in packages: [L2,L1,L2,E1] or fails on compile stage.

Actual

Stack fails while constructing a plan with empty error message:

$ stack  test
 
Warning: Cabal file warning in /home/haskell/stack/L1/L1.cabal@ 0:0: A package
         using section syntax must specify at least 'cabal-version: >= 1.2'.

Warning: Cabal file warning in /home/haskell/stack/L2/L2.cabal@ 0:0: A package
         using section syntax must specify at least 'cabal-version: >= 1.2'.

Warning: Cabal file warning in /home/haskell/stack/E1/E1.cabal@ 0:0: A package
         using section syntax must specify at least 'cabal-version: >= 1.2'.

Error: While constructing the build plan, the following exceptions were encountered:



Some different approaches to resolving this:

  * Set 'allow-newer: true'
    in /home/haskell/.stack/config.yaml to ignore all version constraints and build anyway.

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some
    working build configuration. This can be convenient when dealing with many complicated
    constraint errors, but results may be unpredictable.


Plan construction failed.

Stack version

$ stack --version
Version 1.9.1, Git revision f9d0042c141660e1d38f797e1d426be4a99b2a3c (6168 commits) x86_64 hpack-0.31.0

Method of installation

Official binary, downloaded from stackage.org.

@dbaynard
Copy link
Contributor

Hi @boris-stepanov, thanks for the report. I'll test this out tomorrow. Meanwhile, would you please re-run with --verbose and paste the output here?

Dependency cycle detected in packages: [L2,L1,L2,E1]

The test suites of L1 and E1 depend on L2, and L2 depends on L1. This isn't actually a cycle, correct?

stack may interpret it as a cycle, in which case the backpack preparation changes will help here (I believe much is already in master).

@boris-stepanov
Copy link
Author

Hi @dbaynard, thanks for the response. Here is the gist.
Right, this is not a cycle. We could build them in such progression: L1 -> L2 -> L1 test -> E1 test.

@dbaynard
Copy link
Contributor

OK, I can reproduce

@dbaynard
Copy link
Contributor

I believe the issue is that stack configures packages on a per-package basis, not a per-component basis. (A component is a library, test suite, or executable; a package may have multiple components). I'll try to confirm this.

@dbaynard
Copy link
Contributor

There are a few more variations, too, e.g. does it work with (missing) transitive dependencies where there is no package cycle?

@boris-stepanov
Copy link
Author

boris-stepanov commented Nov 6, 2018

@dbaynard, uhm, sorry, are you waiting for my response?

There are a few more variations, too, e.g. does it work with (missing) transitive dependencies where there is no package cycle?

I am not sure, can you provide cabal files for example?

@dbaynard
Copy link
Contributor

dbaynard commented Nov 7, 2018

Ah, sort of… although (via @snoyberg) packages must have at least a library or executable; E1 has just a test suite. I meant to check that but I haven't had a chance.

Let's try that first, then we can look at my more complicated suggestion… and thank you for your patience.

@dbaynard
Copy link
Contributor

Adding a library stanza to E1 does not fix the issue.

I did some stack dot testing and produced the following:

stack dot

broke-0

stack dot --test

broke-test

With the library stanza in E1, the former becomes

broke-lib

which indicates the rank=max modifier now applies to E1.

@boris-stepanov
Copy link
Author

boris-stepanov commented Nov 16, 2018

Adding "L1" as a dependency for "E1" gives such graph:

test2

It's a surprise, but stack resolves this graph successfully.

@dbaynard
Copy link
Contributor

dbaynard commented Dec 7, 2018

Related: #2583

Actually, this may be a duplicate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants