commercialhaskell / commercialhaskell/stack
ghci impossible panic with PackageImports when missing dependency (global-project)
- Dominant language
- Haskell
- Stars
- 4.1k
- Forks
- 850
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 4
Description
### General summary/comments (optional)
Outside a project, when using `PackageImports`, `stack ghci` and `stack exec -- ghci` panic when a dependency is not already installed.
`$(stack path --compiler-bin)/ghci` works correctly.
### Steps to reproduce
For example:
1. Outside a project, create a file `ghci-fail.hs` as follows, where the import line corresponds to a library that is not already installed. I've used `RIO` for this (as this is how I encountered the bug).
```haskell
{-# LANGUAGE PackageImports #-}
module Main where
import "rio" RIO
main = undefined
```
2. Run command `$(stack path --compiler-bin)/ghci ghci-fail.hs`, then exit ghci.
3. Run command `stack exec -- ghci ghci-fail.hs`, then exit ghci.
4. Run command `stack ghci ghci-fail.hs`, then exit ghci.
Repeat without the `PackageImports` line (remove the `"rio"` from the import line, too).
This error is resolved when `rio` is installed into the `global-project` database.
### Expected
Stack shows an error. This is the same message for 3 as for 2, and possibly the same message for 4, too.
### Actual
With `PackageImports`, 2 shows an error, 3 and 4 panic.
Without `PackageImports` 2, 3 and 4 all show errors.
The outputs for the `PackageImports` variant is here.
Direct invocation
```
> $(stack path --compiler-bin)/ghci ghci-fail.hs
GHCi, version 8.6.3: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from $HOME/.dotfiles/ghci.conf
[1 of 1] Compiling Main ( ghci-fail.hs, interpreted )
ghci-fail.hs:5:1: error:
Could not find module ‘RIO’
It is not a module in the current program, or in any known package.
|
5 | import "rio" RIO
| ^^^^^^^^^^^^^^^^
Failed, no modules loaded.
Prelude Control.Applicative
λ>
Leaving GHCi.
```
stack exec
```
> stack exec -- ghci ghci-fail.hs
GHCi, version 8.6.3: http://www.haskell.org/ghc/ :? for help
package flags have changed, resetting and loading new packages...
Loaded GHCi configuration from $HOME/.dotfiles/ghci.conf
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.3 for x86_64-unknown-linux):
lookupModuleWithSuggestions
rio-0.1.8.0-B2qVfK6MvWnENactXECJIP RIO
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/main/Packages.hs:1927:52 in ghc:Packages
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
λ>
Leaving GHCi.
```
stack ghci
```
> stack ghci ghci-fail.hs
Warning: Couldn't find a component for file target $CWD/ghci-fail.hs. This means that the correct ghc options might not be used.
Attempting to load the file anyway.
Configuring GHCi with the following packages:
GHCi, version 8.6.3: http://www.haskell.org/ghc/ :? for help
package flags have changed, resetting and loading new packages...
Loaded GHCi configuration from $HOME/.dotfiles/ghci.conf
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.3 for x86_64-unknown-linux):
lookupModuleWithSuggestions
rio-0.1.8.0-B2qVfK6MvWnENactXECJIP RIO
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
pprPanic, called at compiler/main/Packages.hs:1927:52 in ghc:Packages
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Loaded GHCi configuration from /tmp/haskell-stack-ghci/bb305186/ghci-script
Prelude Control.Applicative
λ>
```
### Stack version
Arch linux.
```
$ stack --version
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
```
### Method of installation
* Official binary, downloaded from stackage.org or fpcomplete's package repository
Contributor guide
Assessment
This issue has not been assessed yet.