commercialhaskell / stack

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

`stack ghci` fails although stack test attempts a build #533

Closed bitemyapp closed 9 years ago

bitemyapp commented 9 years ago
$ stack ghci
Configuring GHCi with the following packages: Multiprocessing, cryptohash, riak, riak-http, ua-parser, vector-bytestring
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package hspec
    (use -v for more information)
$ stack --version
Version 0.1.2.0, Git revision 6c90f02abbcd73745ec99953c34598a6b1ec41cf

I ran stack build and stack test before-hand, they both reach the build error (type error) in my code.

Possibly related: https://github.com/commercialhaskell/stack/issues/509

pharpend commented 9 years ago

We get this a lot in Snowdrift. If we don't run stack test before stack ghci, we'll get an error like:

cannot satisfy -package yesod-test

I'm not sure if anyone is reported our version yet.

bitemyapp commented 9 years ago

@pharpend I mentioned that

I ran stack build and stack test before-hand

to highlight that my situation seems different somehow.

cocreature commented 9 years ago

I also encountered this problem today after running stack build and stack test. Once I fixed the build error and ran stack build again it worked, but obviously I want ghci to make it easier to get it to work :)

bitemyapp commented 9 years ago

@cocreature I need stack ghci to work even when code is broken, but my stack ghci has had a successful stack build && stack test since then and stack ghci still fails with the same error.

e.g.

All 8 tests passed (0.03s)
Configuring GHCi with the following packages: Multiprocessing, cryptohash, riak, riak-http, ua-parser, vector-bytestring
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package hspec
    (use -v for more information)
pharpend commented 9 years ago

@bitemyapp I know, I was just pointing out another case :)

cocreature commented 9 years ago

@bitemyapp Ah for me the package that couldn't be satisfied was the package I was working on so maybe that explains why it got fixed for me but not for you (assuming you are only using hspec and not working on hspec itself).

cocreature commented 9 years ago

Allright, I found the problem causing the error for me: If the benchsuite (I think the same goes for the test suite, but I've only looked at the code not tried it) depends on the main package, the package is added to the dependencies causing ghci to fail if it has not been built before.

cocreature commented 9 years ago

Allright, I made a simple fix filtering the main package. This fixes the issue I was having.

bitemyapp commented 9 years ago

Still fails with:

$ stack --version
Version 0.1.2.0, Git revision 05ab70d77cbf9490ec7623775669e822a58dfb60
bitemyapp commented 9 years ago

I got further by running stack test before stack ghci, curiously, it runs the tests for all of my vendored dependencies, not just my project.

Prelude> :l src/Main.hs
ghc: /Users/callen/work/gordium/vendor/vector-bytestring/Data/Vector/Storable/ByteString/Internal.hs:12:14-19: Incompatible Safe Haskell flags! (Trustworthy, Unsafe)
Usage: For basic information, try the `--help' option.

There may be good reasons for barfing on this, but cabal repl appears to ignore it and works fine.

I checked and cabal repl has no problem loading my project or the vector-bytestring dependency.

bitemyapp commented 9 years ago

I didn't have my vendored dependencies configured properly, I'm good to go now. I needed to call them out as locations with extra-dep: true :bear: :fearful:

Wizek commented 7 years ago

I've run into this same issue: "cannot satisfy package " with stack 1.4.0.

I don't have extra-deps on the project in question. In fact, it is the yesod-sqlite boilerplate template generated by stack, slightly modified. Also, I haven't quite figured out under what circumstances, but stack 1.1.2 seems to work sometimes when 1.4.0 fails in the aforementioned way on the same project. Could it be a regression?

Edit: Would you prefer if I opened another issue, or if we reopened this one?

mgsloan commented 7 years ago

@Wizek Sure, feel free to open a new issue. However, for me, stack ghci works just fine on the yesod-sqlite template.