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 succeeds (with warnings) despite hidden packages #2333

Open
sjakobi opened this issue Jul 5, 2016 · 7 comments
Open

stack ghci succeeds (with warnings) despite hidden packages #2333

sjakobi opened this issue Jul 5, 2016 · 7 comments

Comments

@sjakobi
Copy link
Member

sjakobi commented Jul 5, 2016

$ stack new repro
$ cd repro
$ # Add dependency on package clock in library section of cabal file
$ # In app/Main.hs: Add import statement for `System.Clock`
$ stack ghci

What I expected: The command fails.

What actually happened:

repro-0.1.0.0: configure
Configuring repro-0.1.0.0...
repro-0.1.0.0: build
Preprocessing library repro-0.1.0.0...
[1 of 1] Compiling Lib              ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/Lib.o )
Preprocessing executable 'repro-exe' for repro-0.1.0.0...

/home/simon/test/repro/app/Main.hs:4:8:
    Could not find module ‘System.Clock’
    It is a member of the hidden package ‘clock-0.7.2@CEVm9DSU9Qg1Hme0DtWvh6’.
    Perhaps you need to add ‘clock’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.

--  While building package repro-0.1.0.0 using:
      /home/simon/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.24.0.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 build lib:repro exe:repro-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
Warning: build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `repro' component exe:repro-exe with main-is file: /home/simon/test/repro/app/Main.hs
Configuring GHCi with the following packages: repro
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Lib              ( /home/simon/test/repro/src/Lib.hs, interpreted )
Ok, modules loaded: Lib.
[2 of 2] Compiling Main             ( /home/simon/test/repro/app/Main.hs, interpreted )
Ok, modules loaded: Lib, Main.

Now, there is a warning, which is good. But if you're using, for example, ghcid, that warning might not be visible to you.

I think it would be better to fail in this case, but maybe I'm overlooking some technicalities of ghci here?

@sjakobi
Copy link
Member Author

sjakobi commented Jul 8, 2016

I just hit this issue again. I'm not sure what kind of errors apart from hidden modules are converted to warnings at this spot, but at least for hidden modules, I'd be in favor of actually erroring out. The problem is easy enough to fix for the user but can be surprising and annoying at a later point.

@mgsloan
Copy link
Contributor

mgsloan commented Jul 19, 2016

Hmm, I cannot reproduce. How is stack invoking ghc? Here's what's in my verbose log:

2016-07-19 16:32:31.672640: [debug] Run process: ghc --interactive -i -odir=/home/mgsloan/fpco/test-stack/repro/.stack-work/odir -hidir=/home/mgsloan/fpco/test-stack/repro/.stack-work/odir -hide-all-packages -i/home/mgsloan/fpco/test-stack/repro/src -i/home/mgsloan/fpco/test-stack/repro/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/autogen -i/home/mgsloan/fpco/test-stack/repro/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build -stubdir=/home/mgsloan/fpco/test-stack/repro/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build -package-id=base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d -i/home/mgsloan/fpco/test-stack/repro/app -i/home/mgsloan/fpco/test-stack/repro/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/repro-exe/repro-exe-tmp -rtsopts -with-rtsopts=-N -optP-include -optP/tmp/ghci16070/cabal_macros.h -ghci-script=/tmp/ghci16070/ghci-script @(DtYP7GyjJjEBTbzQFGsu4c:Stack.Exec src/Stack/Exec.hs:76:5)

Note that -hide-all-packages is being passed. You can actually disable it via --no-package-hiding

@sjakobi
Copy link
Member Author

sjakobi commented Jul 20, 2016

Hmm, I cannot reproduce.

So you don't even get the hidden module warning?

Here's most of my log:

~/t/repro $ stack ghci -v
Version 1.1.3, Git revision 02df1c003fd45a623128cb3cbc86be1e790bdb5e (dirty) (3774 commits) x86_64 hpack-0.14.0
...
2016-07-20 22:41:55.476316: [info] Preprocessing executable 'repro-exe' for repro-0.1.0.0... @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Build.Execute src/Stack/Build/Execute.hs:912:67)
2016-07-20 22:41:55.586827: [warn]  @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Build.Execute src/Stack/Build/Execute.hs:912:67)
2016-07-20 22:41:55.587066: [warn] /home/simon/tmp/repro/app/Main.hs:4:8: @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Build.Execute src/Stack/Build/Execute.hs:912:67)
2016-07-20 22:41:55.587164: [warn]     Could not find module ‘System.Clock’ @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Build.Execute src/Stack/Build/Execute.hs:912:67)
2016-07-20 22:41:55.587242: [warn]     It is a member of the hidden package ‘clock-0.7.2@CEVm9DSU9Qg1Hme0DtWvh6’. @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Build.Execute src/Stack/Build/Execute.hs:912:67)
2016-07-20 22:41:55.587319: [warn]     Perhaps you need to add ‘clock’ to the build-depends in your .cabal file. @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Build.Execute src/Stack/Build/Execute.hs:912:67)
2016-07-20 22:41:55.587409: [warn]     Use -v to see a list of the files searched for. @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Build.Execute src/Stack/Build/Execute.hs:912:67)
2016-07-20 22:41:55.609005: [error] 
--  While building package repro-0.1.0.0 using:
      /home/simon/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.7.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.7.0 build lib:repro exe:repro-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1 @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Ghci src/Stack/Ghci.hs:304:17)
2016-07-20 22:41:55.609257: [warn] Warning: build failed, but optimistically launching GHCi anyway @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Ghci src/Stack/Ghci.hs:305:17)
...
2016-07-20 22:41:55.949235: [warn] The following GHC options are incompatible with GHCi and have not been passed to it: -threaded @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Ghci src/Stack/Ghci.hs:137:9)
2016-07-20 22:41:55.949503: [info] Using main module: 1. Package `repro' component exe:repro-exe with main-is file: /home/simon/tmp/repro/app/Main.hs @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Ghci src/Stack/Ghci.hs:202:28)
2016-07-20 22:41:55.949912: [info] Configuring GHCi with the following packages: repro @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Ghci src/Stack/Ghci.hs:162:5)
2016-07-20 22:41:55.950714: [debug] Run process: ghc --interactive -i -odir=/home/simon/tmp/repro/.stack-work/odir -hidir=/home/simon/tmp/repro/.stack-work/odir -hide-all-packages -i/home/simon/tmp/repro/src -i/home/simon/tmp/repro/.stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build/autogen -i/home/simon/tmp/repro/.stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build -stubdir=/home/simon/tmp/repro/.stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build -package-id=base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d -package-id=clock-0.7.2-CEVm9DSU9Qg1Hme0DtWvh6 -i/home/simon/tmp/repro/app -i/home/simon/tmp/repro/.stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build/repro-exe/repro-exe-tmp -rtsopts -with-rtsopts=-N -optP-include -optP/tmp/ghci10848/cabal_macros.h -ghci-script=/tmp/ghci10848/ghci-script @(stack_FAAzwuEI4kE0v2IiU1PFly:Stack.Exec src/Stack/Exec.hs:76:5)
2016-07-20 22:41:55.951296: [debug] Creating process: /home/simon/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc --interactive -i -odir=/home/simon/tmp/repro/.stack-work/odir -hidir=/home/simon/tmp/repro/.stack-work/odir -hide-all-packages -i/home/simon/tmp/repro/src -i/home/simon/tmp/repro/.stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build/autogen -i/home/simon/tmp/repro/.stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build -stubdir=/home/simon/tmp/repro/.stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build -package-id=base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d -package-id=clock-0.7.2-CEVm9DSU9Qg1Hme0DtWvh6 -i/home/simon/tmp/repro/app -i/home/simon/tmp/repro/.stack-work/dist/x86_64-linux/Cabal-1.22.7.0/build/repro-exe/repro-exe-tmp -rtsopts -with-rtsopts=-N -optP-include -optP/tmp/ghci10848/cabal_macros.h -ghci-script=/tmp/ghci10848/ghci-script @(stack_FAAzwuEI4kE0v2IiU1PFly:System.Process.Run src/System/Process/Run.hs:102:5)
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Lib              ( /home/simon/tmp/repro/src/Lib.hs, interpreted )
Ok, modules loaded: Lib.
[2 of 2] Compiling Main             ( /home/simon/tmp/repro/app/Main.hs, interpreted )
Ok, modules loaded: Lib, Main.
λ> 

@mgsloan
Copy link
Contributor

mgsloan commented Jul 20, 2016

I get the following:

mgsloan@computer:~/fpco/test-stack/repro$ stack ghci
repro-0.1.0.0: unregistering (local file changes: app/Main.hs)
repro-0.1.0.0: build
Preprocessing library repro-0.1.0.0...
Preprocessing executable 'repro-exe' for repro-0.1.0.0...

/home/mgsloan/fpco/test-stack/repro/app/Main.hs:4:8:
    Could not find module ‘System.Clock’
    Use -v to see a list of the files searched for.

--  While building package repro-0.1.0.0 using:
      /home/mgsloan/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.24.0.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 build lib:repro exe:repro-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
Warning: build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `repro' component exe:repro-exe with main-is file: /home/mgsloan/fpco/test-stack/repro/app/Main.hs
Configuring GHCi with the following packages: repro
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
unknown option: 'c'
[1 of 1] Compiling Lib              ( /home/mgsloan/fpco/test-stack/repro/src/Lib.hs, interpreted )
Ok, modules loaded: Lib.

/home/mgsloan/fpco/test-stack/repro/app/Main.hs:4:8:
    Could not find module ‘System.Clock’
    Use -v to see a list of the files searched for.
Failed, modules loaded: Lib.
*Lib Lib> 

@mgsloan
Copy link
Contributor

mgsloan commented Oct 18, 2016

@sjakobi Is this still happening with the latest HEAD version of stack?

@sjakobi
Copy link
Member Author

sjakobi commented Oct 19, 2016

Yes, now even the hidden package warning from stack ghci is gone, so to me the situation is worse than before.

Here's the verbose log of the full repro.

Here's the ghci invocation:

/home/simon/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc --interactive -i  \
  -odir=/home/simon/tmp/repro2333/.stack-work/odir \
  -hidir=/home/simon/tmp/repro2333/.stack-work/odir \
  -hide-all-packages \
  -i/home/simon/tmp/repro2333/src \
  -i/home/simon/tmp/repro2333/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/autogen \
  -i/home/simon/tmp/repro2333/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build \
  -stubdir=/home/simon/tmp/repro2333/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build \
  -package-id=base-4.9.0.0 \
  -package-id=clock-0.7.2-1F3tpzhSilhF4wqwyRWqgE \
  -i/home/simon/tmp/repro2333/app \
  -i/home/simon/tmp/repro2333/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/repro2333-exe/repro2333-exe-tmp \
  -rtsopts \
  -with-rtsopts=-N \
  -optP-include \
  -optP/tmp/ghci15102/cabal_macros.h \
  -ghci-script=/tmp/ghci15102/ghci-script

My expectation still is, that stack ghci should succeed only when stack build does too.

@mgsloan
Copy link
Contributor

mgsloan commented Oct 19, 2016

Something seems fishy here. Note that -hide-all-packages is being passed in, and also -package-id=clock-0.7.2-1F3tpzhSilhF4wqwyRWqgE is being passed in. Why do you expect it to be hidden, it seems like it must be part of your cabal build-depends.

My expectation still is, that stack ghci should succeed only when stack build does too.

We cannot, and have not made that guarantee. For one thing, we mix up all the flags from multiple components. stack ghci working /= stack build working and there isn't much we can do about that. We can hopefully bring intero closer to this by having tighter integration with stack.

The lack of warning is due to the resolution of #1364

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