Skip to content

Instantly share code, notes, and snippets.

@jasagredo
Last active May 11, 2020 13:04
Show Gist options
  • Save jasagredo/0e012304318539f9e2e02fa697836b8d to your computer and use it in GitHub Desktop.
Save jasagredo/0e012304318539f9e2e02fa697836b8d to your computer and use it in GitHub Desktop.
# This has to be parametrized by the compiler version, the project path and the Cabal version
# that is being used. Also the relevant packages to the project will change. In this case I
# just created an empty dummy project to generate the instructions.
# Find ghci script
> stack exec -- which ghci
/usr/local/bin/ghci
# Find ghc script
> cat /usr/local/bin/ghci
#!/bin/sh
exec "/usr/local/bin/ghc-8.6.5" --interactive "$@"
# Find ghc parameters
> cat /usr/local/bin/ghc-8.6.5
#!/bin/sh
exedir="/usr/local/lib/ghc-8.6.5/bin"
exeprog="ghc-stage2"
executablename="$exedir/$exeprog"
datadir="/usr/local/share"
bindir="/usr/local/bin"
topdir="/usr/local/lib/ghc-8.6.5"
executablename="$exedir/ghc"
exec "$executablename" -B"$topdir" ${1+"$@"}
# Get what stack gives to ghci (packages and package-dbs)
> cd <project-dir>
> stack ghci -v
...
[debug] Run process: /usr/local/bin/ghc-pkg-8.6.5 --user --no-user-package-db --package-db /home/javier/.stack/snapshots/x86_64-linux/94cec4cf0471dbaa434989816e6e216f0811ba3760cbdc5d223534834c55b555/8.6.5/pkgdb dump --expand-pkgroot
...
[debug] Run process: /usr/local/bin/ghc-pkg-8.6.5 --user --no-user-package-db --package-db /home/javier/dummy/.stack-work/install/x86_64-linux/94cec4cf0471dbaa434989816e6e216f0811ba3760cbdc5d223534834c55b555/8.6.5/pkgdb dump --expand-pkgroot
...
[debug] Run process: /usr/local/bin/ghc-8.6.5 --interactive -i -odir=/home/javier/dummy/.stack-work/odir -hidir=/home/javier/dummy/.stack-work/odir -hide-all-packages -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build -i/home/javier/dummy/src -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/autogen -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/global-autogen -stubdir=/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build -package-id=base-4.12.0.0 -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe -i/home/javier/dummy/app -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe/autogen -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe/dummy-exe-tmp -rtsopts -with-rtsopts=-N -optP-include -optP/home/javier/dummy/.stack-work/ghci/780d1144/cabal_macros.h -ghci-script=/tmp/haskell-stack-ghci/b8906e7a/ghci-script
...
## Arguments format:
## 1. `-B$topdir` from when we got the ghc parameters
## 2. The beginning of what stack gives ghc until the list of `-package-id`s
## 3. Stack databases (the one in `~/.stack` and the one in `./.stack-work`) from stacks verbose output. Note that previously it had two dashes but now it has only one dash i.e. `-package-db`.
## 4. The rest of what stack gives ghc
> gdb /usr/local/lib/ghc-8.6.5/bin/ghc
(gdb) set args -B/usr/local/lib/ghc-8.6.5 --interactive -i -odir=/home/javier/dummy/.stack-work/odir -hidir=/home/javier/dummy/.stack-work/odir -hide-all-packages -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build -i/home/javier/dummy/src -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/autogen -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/global-autogen -stubdir=/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build -package-db=/home/javier/.stack/snapshots/x86_64-linux/94cec4cf0471dbaa434989816e6e216f0811ba3760cbdc5d223534834c55b555/8.6.5/pkgdb -package-db=/home/javier/dummy/.stack-work/install/x86_64-linux/94cec4cf0471dbaa434989816e6e216f0811ba3760cbdc5d223534834c55b555/8.6.5/pkgdb -package-id=base-4.12.0.0 -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe -i/home/javier/dummy/app -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe/autogen -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe/dummy-exe-tmp -rtsopts -with-rtsopts=-N -optP-include -optP/home/javier/dummy/.stack-work/ghci/780d1144/cabal_macros.h -ghci-script=/tmp/haskell-stack-ghci/b8906e7a/ghci-script
(gdb) run
Starting program: /usr/local/lib/ghc-8.6.5/bin/ghc -B/usr/local/lib/ghc-8.6.5 --interactive -i -odir=/home/javier/dummy/.stack-work/odir -hidir=/home/javier/dummy/.stack-work/odir -hide-all-packages -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build -i/home/javier/dummy/src -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/autogen -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/global-autogen -stubdir=/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build -package-db=/home/javier/.stack/snapshots/x86_64-linux/94cec4cf0471dbaa434989816e6e216f0811ba3760cbdc5d223534834c55b555/8.6.5/pkgdb -package-db=/home/javier/dummy/.stack-work/install/x86_64-linux/94cec4cf0471dbaa434989816e6e216f0811ba3760cbdc5d223534834c55b555/8.6.5/pkgdb -package-id=base-4.12.0.0 -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe -i/home/javier/dummy/app -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe/autogen -i/home/javier/dummy/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/dummy-exe/dummy-exe-tmp -rtsopts -with-rtsopts=-N -optP-include -optP/home/javier/dummy/.stack-work/ghci/780d1144/cabal_macros.h -ghci-script=/tmp/haskell-stack-ghci/b8906e7a/ghci-script
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff06a8700 (LWP 30321)]
[New Thread 0x7fffefea7700 (LWP 30322)]
[New Thread 0x7fffef6a6700 (LWP 30323)]
[New Thread 0x7fffeeea5700 (LWP 30324)]
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
File /home/javier/prototype/dummy/app/Main.hs not found
[1 of 1] Compiling Lib ( /home/javier/dummy/src/Lib.hs, interpreted )
Ok, one module loaded.
Loaded GHCi configuration from /tmp/haskell-stack-ghci/b8906e7a/ghci-script
*Lib Lib>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment