5

I have a .ghci in my local project directory, and another one in my $HOME. When I do a stack ghci, then $HOME/.ghci is loaded first, followed by $PWD/.ghci. Is it possible to have ONLY the local .ghci be loaded, and the global one ignored?

I could do a stack exec -- ghci -ignore-dot-ghci, but then, none is loaded.

What I also tried is:

stack exec -- ghci -ignore-dot-ghci -W .ghci

The idea being to first tell ghci not to load anything and then explicitly requesting the local .ghci file, but this gives the error message Warning: ignoring unrecognised input `.ghci'

user1934428
  • 19,864
  • 7
  • 42
  • 87
  • It seems invoking `stack ghci` from within the project directory should load the local version first (`./.ghci`) and then the global one (`~/.ghci`) but i think there is no way around making stack ignore one of them. However is there a need for this? The global one should have general settings such as the prompt, `:set +s` and some colors perhaps. – Redu May 10 '20 at 13:48

1 Answers1

5

GHCi has a -ghci-script flag which can be used alongside -ignore-dot-ghci. It can be used with stack ghci through --ghci-options:

stack ghci --ghci-options "-ignore-dot-ghci -ghci-script .ghci"

For the sake of completeness, here is the corresponding cabal repl invocation:

cabal repl --repl-options "-ignore-dot-ghci" --repl-options "-ghci-script .ghci"
duplode
  • 33,731
  • 7
  • 79
  • 150