Skip to content
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

stack ghci doesn't work while stack build does #665

Closed
Fuuzetsu opened this issue Jul 23, 2015 · 18 comments
Closed

stack ghci doesn't work while stack build does #665

Fuuzetsu opened this issue Jul 23, 2015 · 18 comments

Comments

@Fuuzetsu
Copy link
Contributor

I have a project here where stack build works happily but stack ghci does not. I would expect that if stack build can build the project, stack ghci should have no problem giving me a repl. I inline the description of the particular issue from the mailing list:

We have a test with

#include <Rversion.h>

This is provided by the R language. On my system, the R/lib is in a
non-standard location.

Nevertheless, my CPP/gcc are wrapped in a script which uses NIX_LDFLAGS
env var which amongst other things has
-L/nix/store/jvvpcckvzybr7y0zmj1x5psb5sy7ipa7-R-3.2.1/lib

So everything works when I stack build.

But when I try to use ‘stack ghci’ on the project, I get

     fatal error: Rversion.h: No such file or directory
     #include <Rversion.h>

Is there anything I can do so ‘stack ghci’ just works like ‘stack build’
does?

In my case it is about CPP being used but this is a bit of a general question.

Using stack from a day or so old git checkout.

@rrnewton
Copy link
Contributor

The LVish project is also one where stack build works but stack ghci fails on stack 0.1.2.0. In its case it fails with the following on Mac OS:

$ stack ghci
Configuring GHCi with the following packages: concurrent-skiplist, lvish, par-classes, par-collections, test-par-collections, par-mergesort, par-transformers
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package criterion
    (use -v for more information)

That looks like maybe a mixup with the dependencies of the different targets. I.e. criterion should only be required for benchmark targets, and thus wasn't built by stack buildalone.

On a related note, I also think it is too bad that stack ghci stops working when a build error breaks stack build. That is, a lot of the time I want to poke around in the repl, or at least use the dependencies when I just broke the build. For example, with stack itself, if you put garbage in a module (say, Main.hs for the executable), then:

$ stack ghci
Configuring GHCi with the following packages: stack
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package stack
    (use -v for more information)

@Fuuzetsu
Copy link
Contributor Author

Yes, test/bench dependencies are another thing that doesn't work out of the box in stack ghci though I can somewhat forgive that seeing as the default is ‘load everything’. Still, it could be smarter.

@snoyberg snoyberg added this to the GHCi milestone Jul 26, 2015
@duplode
Copy link
Contributor

duplode commented Jul 26, 2015

That looks like maybe a mixup with the dependencies of the different targets. I.e. criterion should only be required for benchmark targets, and thus wasn't built by stack buildalone.

I met the same issue when trying to use my GitHub fork of zip-conduit as a dependency, like this:

# stack.yaml snippet.
packages:
- '.'
- location:
    git: https://github.com/duplode/zip-conduit
    commit: 1eefc8bd91d5f38b760bce1fb8dd16d6e05a671d
    extra-dep: true

In such a situation one would never be interested in running the benchmarks of zip-conduit, as it is just another dependency. Adding the extra-dep flag didn't help.

@duplode
Copy link
Contributor

duplode commented Jul 27, 2015

Adding the extra-dep flag didn't help.

Never mind my complaint above - the extra-dep field is wrongly indented. Still, my (non-)issue has lead me to wonder whether it would be appropriate to fix this with a treat-as-dep-in-ghci field (ideally with a less clunky name). By the way, the "load everything in GHCi" behaviour is, as implied by Fuuzetsu's comment, by design. See #130 for the rationale.

@chrisdone
Copy link
Member

Continuing test/bench dependencies in #629 with PR #726.

@chrisdone chrisdone self-assigned this Aug 6, 2015
@chrisdone
Copy link
Member

@Fuuzetsu Do you have a minimal test project I can clone to reproduce and fix?

@mitchellwrosen
Copy link
Contributor

@chrisdone I can describe how to make one, it's simple:

$ stack new
$ vi new-template.cabal
-- add 'tasty' dependency to new-template-test suite
$ stack build
$ stack ghci
Configuring GHCi with the following packages: new-template
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package tasty
    (use -v for more information)

Workaround:

$ stack test
$ stack ghci

@chrisdone
Copy link
Member

I think @mitchellwrosen your problem differs to that of @Fuuzetsu.

@Fuuzetsu
Copy link
Contributor Author

Fuuzetsu commented Aug 9, 2015

Yes, it does. I'm a bit constrained on time right now but maybe I can produce something soon, sorry for delays.

@mitchellwrosen
Copy link
Contributor

Oops, I was looking at @rrnewton's comment. Sorry!

@rpglover64
Copy link

I think I'm having this same issue... to reproduce:

git clone https://github.com/Gabriel439/Haskell-Turtle-Library.git
cd Haskell-Turtle-Library
git checkout da98f7e
stack init
stack build
stack ghci

Expected behavior: ghci is launched with the project loaded
Actual behavior:

Configuring GHCi with the following packages: turtle
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package criterion-1.1.0.0
    (use -v for more information)

@chrisdone
Copy link
Member

@rpglover64 Are you on a recent stack?

@rpglover64
Copy link

Version 0.1.3.0, Git revision 385332d

@chrisdone
Copy link
Member

Your problem's been fixed since then, try latest master. :-)

@rpglover64
Copy link

I'm almost annoyed at how fast stack is moving... On the other hand, my issues are getting fixed. 😃

Thanks.

@ezyang
Copy link

ezyang commented Sep 2, 2015

Hi guys, I've opened a GHC ticket to track this issue. https://ghc.haskell.org/trac/ghc/ticket/10827

@chrisdone
Copy link
Member

Thanks @ezyang!

@borsboom borsboom modified the milestone: GHCi Sep 12, 2015
@borsboom borsboom added this to the P2 milestone Sep 12, 2015
@mgsloan
Copy link
Contributor

mgsloan commented Nov 5, 2015

I'm going to close this issue, since it's old and the GHCi support has had lots of improvements since then. Feel free to open additional issues with concrete cases of the GHCI support being problematic.

Also, I've added some warnings which hopefully will make it clearer why things don't work, at least in the presence of extension flags: #1270

@mgsloan mgsloan closed this as completed Nov 5, 2015
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

10 participants