asterius icon indicating copy to clipboard operation
asterius copied to clipboard

REPL Support

Open malte-v opened this issue 5 years ago • 4 comments

Describe the bug I'm trying to get a GHCi REPL using ahc-cabal new-repl. Instead of giving me a REPL, it prints the following error:

➜  asterius podman run -it --rm -v $(pwd):/mirror -w /mirror --userns keep-id terrorjack/asterius ahc-cabal new-repl
Writing default configuration to /home/asterius/.cabal/config
Renaming /tmp/ahc-cabal-1/config to /tmp/ahc-cabal-1/config.backup.
Writing merged config to /tmp/ahc-cabal-1/config.
Build profile: -w ghc-8.8.3 -O1
In order, the following will be built (use -v for more details):
 - asterius-test-0.1.0.0 (exe:asterius-test) (first run)
Preprocessing executable 'asterius-test' for asterius-test-0.1.0.0..
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
ghc: panic! (the 'impossible' happened)
  (GHC version 8.8.3 for x86_64-unknown-linux):
        lookupGlobal
  Can't find interface-file declaration for data constructor S#
    Probable cause: bug in .hi-boot file, or inconsistent .hi file
    Use -ddump-if-trace to get an idea of which file caused the error
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
        pprPanic, called at compiler/typecheck/TcEnv.hs:133:32 in ghc:TcEnv

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

ahc: callProcess: /home/asterius/.asterius-compiler-bin/ghc "-B/home/asterius/.asterius/.stack-work/install/x86_64-linux-custom-asterius-tinfo6/4040b461a99bb568de931fdb9c30782d01d1c2d8b7e676eef427a1fa09d51a47/8.8.3/share/x86_64-linux-ghc-8.8.3/asterius-0.0.1/.boot/asterius_lib" "--interactive" "-fbuilding-cabal-package" "-O0" "-outputdir" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/asterius-test-tmp" "-odir" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/asterius-test-tmp" "-hidir" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/asterius-test-tmp" "-stubdir" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/asterius-test-tmp" "-i" "-i/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/asterius-test-tmp" "-isrc" "-i/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/autogen" "-i/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/global-autogen" "-I/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/autogen" "-I/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/global-autogen" "-I/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/asterius-test-tmp" "-optP-include" "-optP/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/build/asterius-test/autogen/cabal_macros.h" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "/home/asterius/.cabal/store/ghc-8.8.3/package.db" "-package-db" "/mirror/dist-newstyle/packagedb/ghc-8.8.3" "-package-db" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/asterius-test-0.1.0.0/x/asterius-test/package.conf.inplace" "-package-id" "base-4.13.0.0-6tCQASFaSx1BxXe5DUQ0TH" "-XHaskell2010" "src/Main.hs" "-hide-all-packages" (exit 1): failed
cabal: repl failed for exe:asterius-test from asterius-test-0.1.0.0.

ahc-cabal: callProcess: cabal "--config-file" "/tmp/ahc-cabal-1/config" "new-repl" (exit 1): failed

As you can see, I'm using the Asterius Docker image. I know it said this is a GHC bug, but cabal new-repl works perfectly fine inside the container and AFAIK you're using a custom GHC fork.

To Reproduce

➜  ~ mkdir reproduce
➜  ~ cd reproduce 
➜  reproduce cabal init

Guessing dependencies...

Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating CHANGELOG.md...
Generating Main.hs...
Generating reproduce.cabal...

Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.
➜  reproduce podman run -it --rm -v $(pwd):/mirror -w /mirror --userns keep-id terrorjack/asterius cabal new-repl 
Config file path source is default config file.
Config file /home/asterius/.cabal/config not found.
Writing default configuration to /home/asterius/.cabal/config
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.RemoteRepo {remoteRepoName = "hackage.haskell.org",
remoteRepoURI = http://hackage.haskell.org/, remoteRepoSecure = Just True,
remoteRepoRootKeys =
["fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0","1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42","2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3","0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d","51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921"],
remoteRepoKeyThreshold = 3, remoteRepoShouldTryHttps = True}
Resolving dependencies...
Build profile: -w ghc-8.8.3 -O1
In order, the following will be built (use -v for more details):
 - reproduce-0.1.0.0 (exe:reproduce) (first run)
Configuring executable 'reproduce' for reproduce-0.1.0.0..
Warning: The 'license-file' field refers to the file 'LICENSE' which does not
exist.
Preprocessing executable 'reproduce' for reproduce-0.1.0.0..
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( Main.hs, interpreted )
Ok, one module loaded.
*Main> :q
Leaving GHCi.
➜  reproduce podman run -it --rm -v $(pwd):/mirror -w /mirror --userns keep-id terrorjack/asterius ahc-cabal new-repl
Writing default configuration to /home/asterius/.cabal/config
Renaming /tmp/ahc-cabal-1/config to /tmp/ahc-cabal-1/config.backup.
Writing merged config to /tmp/ahc-cabal-1/config.
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.RemoteRepo {remoteRepoName = "hackage.haskell.org",
remoteRepoURI = http://hackage.haskell.org/, remoteRepoSecure = Just True,
remoteRepoRootKeys =
["fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0","1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42","2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3","0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d","51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921"],
remoteRepoKeyThreshold = 3, remoteRepoShouldTryHttps = True}
Resolving dependencies...
Build profile: -w ghc-8.8.3 -O1
In order, the following will be built (use -v for more details):
 - reproduce-0.1.0.0 (exe:reproduce) (configuration changed)
Configuring executable 'reproduce' for reproduce-0.1.0.0..
Warning: The 'license-file' field refers to the file 'LICENSE' which does not
exist.
Preprocessing executable 'reproduce' for reproduce-0.1.0.0..
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
ghc: panic! (the 'impossible' happened)
  (GHC version 8.8.3 for x86_64-unknown-linux):
	lookupGlobal
  Can't find interface-file declaration for data constructor S#
    Probable cause: bug in .hi-boot file, or inconsistent .hi file
    Use -ddump-if-trace to get an idea of which file caused the error
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
        pprPanic, called at compiler/typecheck/TcEnv.hs:133:32 in ghc:TcEnv

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

ahc: callProcess: /home/asterius/.asterius-compiler-bin/ghc "-B/home/asterius/.asterius/.stack-work/install/x86_64-linux-custom-asterius-tinfo6/4040b461a99bb568de931fdb9c30782d01d1c2d8b7e676eef427a1fa09d51a47/8.8.3/share/x86_64-linux-ghc-8.8.3/asterius-0.0.1/.boot/asterius_lib" "--interactive" "-fbuilding-cabal-package" "-O0" "-outputdir" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/reproduce-tmp" "-odir" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/reproduce-tmp" "-hidir" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/reproduce-tmp" "-stubdir" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/reproduce-tmp" "-i" "-i/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/reproduce-tmp" "-i." "-i/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/autogen" "-i/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/global-autogen" "-I/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/autogen" "-I/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/global-autogen" "-I/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/reproduce-tmp" "-optP-include" "-optP/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/build/reproduce/autogen/cabal_macros.h" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "/home/asterius/.cabal/store/ghc-8.8.3/package.db" "-package-db" "/mirror/dist-newstyle/packagedb/ghc-8.8.3" "-package-db" "/mirror/dist-newstyle/build/x86_64-linux/ghc-8.8.3/reproduce-0.1.0.0/x/reproduce/package.conf.inplace" "-package-id" "base-4.13.0.0-6tCQASFaSx1BxXe5DUQ0TH" "-XHaskell2010" "./Main.hs" "-hide-all-packages" (exit 1): failed
cabal: repl failed for exe:reproduce from reproduce-0.1.0.0.

ahc-cabal: callProcess: cabal "--config-file" "/tmp/ahc-cabal-1/config" "new-repl" (exit 1): failed

Expected behavior ahc-cabal new-repl gives me a REPL instead of an error.

Environment

  • OS name + version:
➜  ~ uname -a
Linux linux 5.6.4-arch1-1 #1 SMP PREEMPT Mon, 13 Apr 2020 12:21:19 +0000 x86_64 GNU/Linux
  • Version of the code: Not sure what "the code" is referring to. Please elaborate if you need this information.

malte-v avatar Apr 25 '20 12:04 malte-v

Possibly related: https://github.com/haskell/haskell-ide-engine/issues/1100

malte-v avatar Apr 26 '20 13:04 malte-v

We don't support REPL yet.

TerrorJack avatar Apr 27 '20 07:04 TerrorJack

I see, do you think this would be difficult to implement? I don't know much about how GHCi works but I'd be happy to help out.

malte-v avatar Apr 27 '20 08:04 malte-v

Cross-compilation is not well supported by GHC/GHCi (see https://github.com/hsyl20/ghc-cross-compilation).

This particular error is probably due to the fact that GHC was built with integer-gmp but Asterius uses integer-simple. It should be fixed upstream by https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2231 in GHC 8.12.

hsyl20 avatar May 10 '20 13:05 hsyl20