commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.99k stars 845 forks source link

UI improvement on "Build plan did not match your requirements" #501

Closed k-bx closed 9 years ago

k-bx commented 9 years ago

I just wanted to build some haddocks on https://github.com/Gabriel439/lens repo to check out Gabriel's lens tutorial, and found one place for improvement.

Current experience:

➜  lens-gabriel git:(master) stack haddock
Unable to find a stack.yaml file in the current directory (/Users/kb/workspace/lens-gabriel/) or its ancestors
Recommended action: stack init
Writing default config file to: /Users/kb/workspace/lens-gabriel/stack.yaml
Basing on cabal files:
- /Users/kb/workspace/lens-gabriel/lens.cabal
- /Users/kb/workspace/lens-gabriel/examples/lens-examples.cabal
- /Users/kb/workspace/lens-gabriel/lens-properties/lens-properties.cabal

Checking against build plan lts-2.16

* Build plan did not match your requirements:
    base-orphans not found
    - lens requires >=0.3 && <1

    bifunctors version 4.2.1 found
    - lens requires >=5 && <6

    gloss not found
    - lens-examples requires ==1.7.*

    profunctors version 4.4.1 found
    - lens requires >=5 && <6

    random version 1.1 found
    - lens-examples requires ==1.0.*

    semigroupoids version 4.3 found
    - lens requires >=5 && <6

Caching build plan
Checking against build plan lts-2.14
[...]
Downloaded lts-1.15 build plan.
Caching build plan
Checking against build plan lts-1.15
[...]
Downloaded nightly-2015-07-02 build plan.
Caching build plan
Checking against build plan nightly-2015-07-02
[...]

There was no snapshot found that matched the package bounds in your .cabal files.
Please choose one of the following commands to get started.

    stack init --resolver lts-2.16
    stack init --resolver lts-2.14
    stack init --resolver lts-1.15
    stack init --resolver nightly-2015-07-02

You'll then need to add some extra-deps. See:

    https://github.com/commercialhaskell/stack/wiki/stack.yaml#extra-deps

You can also try falling back to a dependency solver with:

    stack init --solver
➜  lens-gabriel git:(master) stack init --resolver lts-2.16
Writing default config file to: /Users/kb/workspace/lens-gabriel/stack.yaml
Basing on cabal files:
- /Users/kb/workspace/lens-gabriel/lens.cabal
- /Users/kb/workspace/lens-gabriel/examples/lens-examples.cabal
- /Users/kb/workspace/lens-gabriel/lens-properties/lens-properties.cabal

Checking against build plan lts-2.16

* Build plan did not match your requirements:
    base-orphans not found
    - lens requires >=0.3 && <1

    bifunctors version 4.2.1 found
    - lens requires >=5 && <6

    gloss not found
    - lens-examples requires ==1.7.*

    profunctors version 4.4.1 found
    - lens requires >=5 && <6

    random version 1.1 found
    - lens-examples requires ==1.0.*

    semigroupoids version 4.3 found
    - lens requires >=5 && <6

Selected resolver: lts-2.16
Wrote project config to: /Users/kb/workspace/lens-gabriel/stack.yaml

From this point, it is clear (to me), that the next desired step would be to add extra-deps into latest (or other desired) versions of these packages, but it might not be clear for a new user.

Possible solutions:

  1. Output "Recommended action: run "stack build" and see recommendations on fixing dependency errors". This will run a nice "stack build", which also shows latest versions available, and will tell to add stuff to extra-deps.
  2. Improve output of stack init --resolver lts-2.16 to be more like stack build output in terms of telling what to do to fix the issues.

Thanks!

k-bx commented 9 years ago

Somewhat related, after adding:

extra-deps:
- base-orphans-0.4.0
- gloss-1.9.4.1
- gloss-rendering-1.9.3.1

I run stack build and see:

➜  lens-gabriel git:(master) ✗ stack build
While constructing the BuildPlan the following exceptions were encountered:

--  Failure when adding dependencies:
      base: needed (==4.8.*), latest is 4.8.0.0, but 4.7.0.2 found
      ghc-prim: needed (==0.4.*), latest is 0.4.0.0, but 0.3.1.0 found
      gloss-rendering: needed (==1.9.3.*), latest is 1.9.3.1, but couldn't resolve its dependencies
    needed for package: gloss-1.9.4.1

--  Failure when adding dependencies:
      base: needed (==4.8.*), latest is 4.8.0.0, but 4.7.0.2 found
    needed for package: gloss-rendering-1.9.3.1

--  Failure when adding dependencies:
      bifunctors: needed (>=5 && <6), latest is 5, but 4.2.1 found
      profunctors: needed (>=5 && <6), latest is 5.1.1, but 4.4.1 found
      semigroupoids: needed (>=5 && <6), latest is 5.0.0.2, but 4.3 found
    needed for package: lens-4.11

--  Failure when adding dependencies:
      gloss: needed (==1.7.*), latest is 1.9.4.1, but couldn't resolve its dependencies
      lens: needed (-any), latest is 4.11, but couldn't resolve its dependencies
      random: needed (==1.0.*), latest is 1.1, but 1.1 found
    needed for package: lens-examples-0.1

--  Failure when adding dependencies:
      lens: needed (>=4 && <5), latest is 4.11, but couldn't resolve its dependencies
    needed for package: lens-properties-4.11

Why does it need base of ==4.8.*? lts-2.16 lists 4.7.0.2, lens.cabal asks for < 5. Really confusing to me.

UPDATE: sorry, this is resolved, I see the "needed for package" at the bottom now. On the other hand, those package-versions were advised to me by stack build, so it would be nice to check if they will match versions before recommending them.

snoyberg commented 9 years ago

There's already an open issue to get more precise information about recommendations (#116). This entails having a full dependency solver, which we're waiting on other people to provide. In the interim, the stack solver command will use cabal's dependency solver. We don't do that by default though due to the many bugs that exist there.