commercialhaskell / commercialhaskell/stack

`stack ghci` succeeds (with warnings) despite hidden packages

Open
#2,333 7 comments 0 reactions 0 assignees View on GitHub
component: ghci component: output (UI/UX) type: discuss
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

```
$ 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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.