fpco/ide-backend

stack ghci does not work

jaccokrijnen opened this issue · 5 comments

I hoped to play around a bit in ghci, but stack ghci gives me the following:

Configuring GHCi with the following packages: ide-backend-common, ide-backend-server, ide-backend

on the commandline: Warning:
    -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package tasty
    (use -v for more information)
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.2
$ cabal --version
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library 

using -v gives

Version 0.1.2.0, Git revision 65246552936b7da4b64b38372feac903d96a8911 (dirty)
2015-08-05 12:03:21.759251: [debug] Checking for project config at: /home/jacco/projects/ide-backend/stack.yaml @(stack-0.1.2.0:Stack.Config src/Stack/Config.hs:496:9)
2015-08-05 12:03:21.75961: [debug] Loading project config file stack.yaml @(stack-0.1.2.0:Stack.Config src/Stack/Config.hs:519:13)
2015-08-05 12:03:21.772391: [debug] Run process: ghc --info @(stack-0.1.2.0:System.Process.Read src/System/Process/Read.hs:254:3)
2015-08-05 12:03:21.83039: [debug] Run process: ghc --numeric-version @(stack-0.1.2.0:System.Process.Read src/System/Process/Read.hs:254:3)
2015-08-05 12:03:21.858968: [debug] Run process: ghc-pkg --no-user-package-db field --simple-output Cabal id @(stack-0.1.2.0:System.Process.Read src/System/Process/Read.hs:254:3)
2015-08-05 12:03:21.890003: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack-0.1.2.0:System.Process.Read src/System/Process/Read.hs:254:3)
2015-08-05 12:03:21.967219: [info] Configuring GHCi with the following packages: ide-backend-common, ide-backend-server, ide-backend @(stack-0.1.2.0:Stack.Repl src/Stack/Repl.hs:69:5)
2015-08-05 12:03:21.967571: [debug] Run process: /opt/ghc/7.10.2/bin/ghc --interactive -hide-all-packages -Wall -fno-warn-unused-do-bind -XCPP -XDeriveDataTypeable -XDeriveFoldable -XDeriveFunctor -XDeriveGeneric -XDeriveTraversable -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XMultiParamTypeClasses -XNamedFieldPuns -XRankNTypes -XRecordWildCards -XScopedTypeVariables -XStandaloneDeriving -XTemplateHaskell -XTypeFamilies -XTypeSynonymInstances -i/home/jacco/projects/ide-backend/ide-backend-common/ -i/home/jacco/projects/ide-backend/ide-backend-common/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/ -optP-include -optP/home/jacco/projects/ide-backend/ide-backend-common/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h -package=base -package=filepath -package=directory -package=containers -package=bytestring -package=mtl -package=async -package=aeson -package=unix -package=temporary -package=bytestring-trie -package=text -package=fingertree -package=binary -package=data-accessor -package=crypto-api -package=pureMD5 -package=tagged -package=transformers -package=attoparsec -package=template-haskell -package=pretty-show -package=monad-logger -hide-all-packages -Wall -rtsopts -with-rtsopts=-c -with-rtsopts=-I0 -dynamic -XMonoLocalBinds -XBangPatterns -XRecordWildCards -XNamedFieldPuns -XTemplateHaskell -i/home/jacco/projects/ide-backend/ide-backend-server/ -i/home/jacco/projects/ide-backend/ide-backend-server/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/ -optP-include -optP/home/jacco/projects/ide-backend/ide-backend-server/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h -package=base -package=ghc -package=containers -package=bytestring -package=data-accessor -package=data-accessor-mtl -package=async -package=unix -package=text -package=directory -package=filepath -package=process -package=transformers -package=mtl -package=unordered-containers -package=filemanip -package=array -package=temporary -package=tar -package=zlib -package=file-embed -package=ide-backend-common -package=time -package=haddock-api -package=Cabal -hide-all-packages -Wall -fno-warn-unused-do-bind -XMonoLocalBinds -XBangPatterns -XRecordWildCards -XNamedFieldPuns -XRankNTypes -XMultiParamTypeClasses -XExistentialQuantification -XFlexibleContexts -XDeriveDataTypeable -XCPP -XTemplateHaskell -XScopedTypeVariables -XGeneralizedNewtypeDeriving -i/home/jacco/projects/ide-backend/ide-backend/ -i/home/jacco/projects/ide-backend/ide-backend/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/ -optP-include -optP/home/jacco/projects/ide-backend/ide-backend/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h -package=base -package=filemanip -package=process -package=filepath -package=directory -package=containers -package=bytestring -package=mtl -package=async -package=unix -package=temporary -package=text -package=binary -package=data-accessor -package=data-accessor-mtl -package=pureMD5 -package=transformers -package=time -package=attoparsec -package=utf8-string -package=ide-backend-common -package=template-haskell -package=Cabal-ide-backend -package=ghc-prim -package=pretty-show -package=ide-backend -package=random -package=aeson -package=executable-path -package=bytestring-trie -package=unordered-containers -package=fingertree -package=crypto-api -package=tagged -with-rtsopts=-N -XOverloadedStrings -XTypeSynonymInstances -XFlexibleInstances -XOverlappingInstances -i/home/jacco/projects/ide-backend/ide-backend/TestSuite/ -i/home/jacco/projects/ide-backend/ide-backend/test/ -package=tasty -package=HUnit -package=regex-compat -package=stm -package=deepseq -package=parallel -package=monads-tf -package=test-framework -package=test-framework-hunit /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/GHC/API.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/GHC/Requests.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/GHC/Responses.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/RPC/API.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/RPC/Server.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/RPC/Stream.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/Container.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/IORef.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/IntMap.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/IntervalMap.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/List.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/MVar.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/Map.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/Maybe.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/Pair.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/StateT.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Strict/Trie.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Types/Private.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Types/Progress.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Types/Public.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Types/Translation.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Util.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Util/BlockingOps.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Util/Logger.hs /home/jacco/projects/ide-backend/ide-backend-common/IdeSession/Util/PrettyVal.hs /home/jacco/projects/ide-backend/ide-backend-server/Break.hs /home/jacco/projects/ide-backend/ide-backend-server/Conv.hs /home/jacco/projects/ide-backend/ide-backend-server/Debug.hs /home/jacco/projects/ide-backend/ide-backend-server/FilePathCaching.hs /home/jacco/projects/ide-backend/ide-backend-server/GhcShim.hs /home/jacco/projects/ide-backend/ide-backend-server/GhcShim/API.hs /home/jacco/projects/ide-backend/ide-backend-server/GhcShim/GhcShim710.hs /home/jacco/projects/ide-backend/ide-backend-server/GhcShim/GhcShim742.hs /home/jacco/projects/ide-backend/ide-backend-server/GhcShim/GhcShim78.hs /home/jacco/projects/ide-backend/ide-backend-server/Haddock.hs /home/jacco/projects/ide-backend/ide-backend-server/HsWalk.hs /home/jacco/projects/ide-backend/ide-backend-server/IdPropCaching.hs /home/jacco/projects/ide-backend/ide-backend-server/Posix.hsc /home/jacco/projects/ide-backend/ide-backend-server/RTS.hs /home/jacco/projects/ide-backend/ide-backend-server/Run.hs /home/jacco/projects/ide-backend/ide-backend-server/Server.hs /home/jacco/projects/ide-backend/ide-backend-server/TraceMonad.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/Cabal.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/Config.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/ExeCabalClient.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/ExeCabalServer.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/GHC/Client.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/Licenses.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/Query.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/RPC/Client.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/State.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/Update.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/Update/ExecuteSessionUpdate.hs /home/jacco/projects/ide-backend/ide-backend/IdeSession/Update/IdeSessionUpdate.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Assertions.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Session.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/State.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/API.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Autocompletion.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/BufferMode.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/BuildDoc.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/BuildExe.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/BuildLicenses.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/C.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/CabalMacros.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Compilation.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Compliance.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Concurrency.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Crash.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Debugger.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/FFI.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Integration.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/InterruptRunExe.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/InterruptRunStmt.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Issues.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Packages.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Performance.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/Pseudoterminal.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/SessionRestart.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/SessionState.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/SnippetEnvironment.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/StdIO.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/TH.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/TypeInformation.hs /home/jacco/projects/ide-backend/ide-backend/TestSuite/TestSuite/Tests/UpdateTargets.hs /home/jacco/projects/ide-backend/ide-backend/test/TestTools.hs @(stack-0.1.2.0:Stack.Exec src/Stack/Exec.hs:52:5)

on the commandline: Warning:
    -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package tasty
    (use -v for more information)

Run stack test first, that'll install tasty.

Thanks, ghci starts but it seems that my ghc is not supported? (the changelog mentions support for 7.10)

jacco@tm-86:~/projects/ide-backend$ stack ghci
Configuring GHCi with the following packages: ide-backend-common, ide-backend-server, ide-backend

on the commandline: Warning:
    -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
Warning: ignoring unrecognised input `/home/jacco/projects/ide-backend/ide-backend-server/Posix.hsc'

In file included from <command-line>:10:0: 

/home/jacco/projects/ide-backend/ide-backend-server/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h:248:0:
     warning: "CURRENT_PACKAGE_KEY" redefined [enabled by default]
     #define CURRENT_PACKAGE_KEY "ideba_EjTmSymrltzHlvseI61e07"
     ^

... many more CURRENT_PACKAGE_KEY warnings ...

/home/jacco/projects/ide-backend/ide-backend-server/GhcShim.hs:53:2:
     error: #error "Unsupported GHC version"
     #error "Unsupported GHC version"
      ^
phase `C pre-processor' failed (exitcode = 1)
> import IdeSession

<interactive>:1:1:
    attempting to use module ‘IdeSession’ (/home/jacco/projects/ide-backend/ide-backend/IdeSession.hs) which is not loaded

It's not that your GHC is unsupported, this is a confusing error message. I've changed it to #error "No GHC_* CPP flag specified, possibly using an unsupported GHC version", particularly since this isn't the first time I've seen this error cause confusion. 9da1fb0

I'm thinking the issue is that stack ghci is not passing the CPP flags to GHCI. Here's where those CPP flags are defined: https://github.com/fpco/ide-backend/blob/master/ide-backend-server/ide-backend-server.cabal#L70

Is there a way to manually pass them (using ghc-options perhaps)?

Good point! I've made a couple of changes to ide-backend-server, and now this works for me:

(running from within the ide-backend-server directory)

stack build    # necessary to generate `ide-backend-server/embedded-rts.tgz`
stack ghci --ghc-options "-DGHC_710 -DGHC_AFTER_710_1" ide-backend-server

Unfortunately, stack ghci ide-backend doesn't yet work, because stack ghci combines the dependencies and flags from both the library and test-suite. This causes a module ambiguity between mtl and monads-tf. Why is monads-tf in the list? It's not a real dependency of the test-suite, it just expects it at runtime. Probably the test-suite should be modified to install these extra packages when they're missing.