litxio / ptghci

High-powered REPL for Haskell, inspired by IPython
Other
336 stars 6 forks source link

Hangs when running in folder with `stack.yaml` and `package.yaml` #24

Closed MatthewScholefield closed 4 years ago

MatthewScholefield commented 4 years ago

I'm not sure if I'm doing something wrong, but if I run ptghci in a folder that has a project it just hangs:

$ cat stack.yaml
resolver: lts-16.13
packages: [.]
$ cat package.yaml
name: my-package
tests:
  tests-test:
    main: Main.hs
    source-dirs: []
$ ptghci
Configuring GHCi with the following packages: mp1-haskell
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
^C^CRe-sending interrupt
^CRe-sending interrupt
^Z[1]  + 22776 suspended (signal)  ptghci
$ kill -9 %1
[1]  + 22776 killed     ptghci

Here is the relevant output of ptghci when ran with -v:

2020-09-13 18:09:25.394613: [info] Configuring GHCi with the following packages: my-package
2020-09-13 18:09:25.394816: [debug] Run process: /home/matthew/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4/bin/ghc-8.8.4 --version
2020-09-13 18:09:25.425758: [debug] Process finished in 31ms: /home/matthew/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4/bin/ghc-8.8.4 --version
2020-09-13 18:09:25.425975: [debug] Run process: /home/matthew/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4/bin/ghc-8.8.4 --interactive -i -odir=/home/matthew/tmp10/.stack-work/odir -hidir=/home/matthew/tmp10/.stack-work/odir -hide-all-packages -ghci-script=/tmp/haskell-stack-ghci/2a3bbd58/ghci-script
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help

Full output is here.

RichardWarfield commented 4 years ago

Could you let me know what happens if you run plain old stack ghci in the same directory?

MatthewScholefield commented 4 years ago

Sure, running that I get a normal interactive session. One thing to note is that by default it doesn't load the base package. Not sure if this is normal since I'm new to Haskell:

$ stack ghci               
Configuring GHCi with the following packages: my-package
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /tmp/haskell-stack-ghci/2a3bbd58/ghci-script
> a = "hello"
> a
"hello"
> 12 + 2

<interactive>:3:4: error:
    Variable not in scope:
      (+)
        :: integer-gmp-1.0.2.0:GHC.Integer.Type.Integer
           -> integer-gmp-1.0.2.0:GHC.Integer.Type.Integer -> t

Running with --package base fixes it:

$ stack ghci --package base
Configuring GHCi with the following packages: my-package
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /tmp/haskell-stack-ghci/2a3bbd58/ghci-script
Prelude> 12 + 2
14
RichardWarfield commented 4 years ago

OK, that's very weird but probably explains why ptghci is choking. Is base listed as a dependency in your package.yaml?

MatthewScholefield commented 4 years ago

I modified it so it included base >= 4.9 && < 5 as a dependency and the behavior was the same. I've been searching for more than an hour now and can't quite figure out what's wrong with my stack ghci but it seems like it's not a problem with ptghci. I got around it by adding ghciCommand: stack ghci --package base to ~/.ptghci.yaml.