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 at global level missing base #3589

Closed
MarcelineVQ opened this Issue Nov 19, 2017 · 15 comments

Comments

Projects
None yet
4 participants
@MarcelineVQ

MarcelineVQ commented Nov 19, 2017

Something recent, possibly the 5b58500 commit, is causing errors such as:

 <interactive>:1:19: error:
    Not in scope: ‘System.IO.hSetBuffering’
    No module named ‘System.IO’ is imported.

<interactive>:1:43: error:
    Not in scope: ‘System.IO.stdin’
    No module named ‘System.IO’ is imported.

<interactive>:1:60: error:
    Not in scope: data constructor ‘System.IO.NoBuffering’
    No module named ‘System.IO’ is imported.

When stack ghci is ran outside of any project's scope. These are resolved by specifying
stack ghci --package base

@snoyberg

This comment has been minimized.

Contributor

snoyberg commented Nov 21, 2017

I think this is affecting intero as well, which recently stopped working for me. CC @mgsloan

@snoyberg snoyberg added this to the P0: Blocking release milestone Nov 21, 2017

@mgsloan

This comment has been minimized.

Collaborator

mgsloan commented Nov 22, 2017

Fixed in 196bdba thanks for the report @MarcelineVQ !

@mgsloan mgsloan closed this Nov 22, 2017

@effectfully

This comment has been minimized.

effectfully commented Jan 7, 2018

I did stack upgrade --git, but I still see those errors about System.IO.

Here is how you can reproduce:

stack.yaml:

resolver: lts-9.13

nobase-bug.cabal:

name:                nobase-bug
version:             0.1.0.0
build-type:          Simple
cabal-version:       >= 1.2

executable nobase-bug
  hs-source-dirs:      src
  main-is:             Main.hs
  default-language:    Haskell2010
  default-extensions:  NoImplicitPrelude
  build-depends:       rerebase

src/Main.hs:

module Main where

import Prelude

main = return ()

Then run stack ghci inside the project.

@mgsloan

This comment has been minimized.

Collaborator

mgsloan commented Jan 8, 2018

@effectfully Are you sure that the stack binary written by upgrade is on your path? Ensure that stack --version reports 1.7.0

@effectfully

This comment has been minimized.

effectfully commented Jan 8, 2018

@mgsloan, I checked it before reporting. Here is the output of stack --version:

Version 1.7.0, Git revision 6b9da26bf17c682a5db583f1a5484d4762467a82 x86_64 hpack-0.20.0
@mgsloan

This comment has been minimized.

Collaborator

mgsloan commented Jan 8, 2018

Huh! For me NoImplicitPrelude works with ghci 8.0.2 . I don't suppose stack ghc -- --version reports something else?

You might try switching to lts-10 (ghc 8.2). I can't find it now but IIRC there was a bug in ghc's tracker about NoImplicitPrelude + ghci. There is still a bug there for ghci + -XSafe

@effectfully

This comment has been minimized.

effectfully commented Jan 8, 2018

stack ghc -- --version reports GHC is 8.0.2. NoImplicitPrelude + GHC-8.0.2 has been working just fine for me for month.

The funny thing is that if you comment out build-depends: rerebase, then stack ghci runs without any problems. Sorry, should have said this. So that dependency is crucial somehow. Do you have any ideas? A bug in GHC?

@snoyberg

This comment has been minimized.

Contributor

snoyberg commented Jan 9, 2018

Sounds like ghci is getting confused about which System.IO to use, since rerebase is providing its own.

@effectfully

This comment has been minimized.

effectfully commented Jan 9, 2018

@snoyberg, the errors would be different then:

<interactive>:1:6: error:
    Not in scope: ‘System.IO.hSetBuffering’
    No module named ‘System.IO’ is imported.

<interactive>:1:30: error:
    Not in scope: ‘System.IO.stdin’
    No module named ‘System.IO’ is imported.

<interactive>:1:46: error:
    Not in scope: data constructor ‘System.IO.NoBuffering’
    No module named ‘System.IO’ is imported.

<interactive>:1:70: error:
    Not in scope: ‘System.IO.hSetBuffering’
    No module named ‘System.IO’ is imported.

<interactive>:1:94: error:
    Not in scope: ‘System.IO.stdout’
    No module named ‘System.IO’ is imported.

<interactive>:1:111: error:
    Not in scope: data constructor ‘System.IO.NoBuffering’
    No module named ‘System.IO’ is imported.

<interactive>:1:135: error:
    Not in scope: ‘System.IO.hSetBuffering’
    No module named ‘System.IO’ is imported.

<interactive>:1:159: error:
    Not in scope: ‘System.IO.stderr’
    No module named ‘System.IO’ is imported.

<interactive>:1:176: error:
    Not in scope: data constructor ‘System.IO.NoBuffering’
    No module named ‘System.IO’ is imported.
@effectfully

This comment has been minimized.

effectfully commented Jan 16, 2018

When I start intero and write import Prelude, I get Ambiguous interface for 'Prelude', so there is indeed some confusion, but :load in plain ghci works just fine.

I'm currently using intero as a text editor rather than an IDE and it's extremely annoying, I don't want to switch back to the cabal ecosystem just because there is a single bug, but this bug is total show stopper for me. Could you at least reopen the issue?

@mgsloan

This comment has been minimized.

Collaborator

mgsloan commented Jan 17, 2018

Sure.

What do you get for stack ghci -v? It will tell you how it is invoking ghci, please try to figure out how the invocation needs to change.

What do you get for stack exec -- ghc-pkg describe base ?

@mgsloan mgsloan reopened this Jan 17, 2018

@effectfully

This comment has been minimized.

effectfully commented Jan 19, 2018

I get

Run process: /home/effectfully/.stack/programs/x86_64-linux/ghc-8.0.2/bin/ghc --interactive -i -odir=/home/effectfully/code/nobase-bug/.stack-work/odir -hidir=/home/effectfully/code/nobase-bug/.stack-work/odir -hide-all-packages -package base -XNoImplicitPrelude -i/home/effectfully/code/nobase-bug/src -i/home/effectfully/code/nobase-bug/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen -i/home/effectfully/code/nobase-bug/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build -i/home/effectfully/code/nobase-bug/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/nobase-bug/nobase-bug-tmp -stubdir=/home/effectfully/code/nobase-bug/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build -package-id=rerebase-1.0.3-GUoprUfp95pIfBD9KsEXFK -optP-include -optP/tmp/ghci26488/cabal_macros.h -ghci-script=/tmp/ghci26488/ghci-script

for stack ghci -v. I see -package base there, can this be a culprit?

stack exec -- ghc-pkg describe base results in

name: base
version: 4.9.1.0
...

Here is the full output.

I started to use -XPackageImports to disambiguate Prelude and even though intero "exits abnormally with code 1", type checking, go-to-definition and other tools except ghci work, so it's not a show stopper for me anymore. Still would be nice to get ghci working ofc.

@mgsloan

This comment has been minimized.

Collaborator

mgsloan commented Jan 20, 2018

Ah, this is indeed caused by 196bdba

The reason for -package base was that ghci doesn't start unless something providing these System.IO functions is in scope.

I fixed it! 99950cf

@mgsloan mgsloan closed this Jan 20, 2018

@effectfully

This comment has been minimized.

effectfully commented Jan 22, 2018

I've checked, it works. Thank you.

@mgsloan

This comment has been minimized.

Collaborator

mgsloan commented Jan 22, 2018

Welcome! Thanks for verifying

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