I'm using stack ghci
to start my REPL, based on the answer I got for my question on how to import a module installed with stack
. This works fine, but I get initially a warning message Note: No local targets specified, so a plain ghci will be started with no package hiding or package options., followed by a bunch of suggestions about package hiding and options. My guess is that this is because I have not used stack init
to setup a project, since I am still in the "playing around and learning" state and don't want a project yet. I have not found an explanation about the meaning of 'no local targets', but the effect to start a plain ghci is exactly what I want at that point. Is there a way to suppress this message? I looked at stack --help
, but could not find something suitable.
Asked
Active
Viewed 630 times
5

user1934428
- 19,864
- 7
- 42
- 87
2 Answers
3
As the Note
(not warning) suggests, a plain ghci is started, which is rather uncommon situation when working with stack
.
~$ stack ghci
Note: No local targets specified, so a plain ghci will be started with no package hiding or package options.
You are using snapshot: lts-14.12
If you want to use package hiding and options, then you can try one of the following:
* If you want to start a different project configuration than /home/username/.stack/global-project/stack.yaml, then you can use stack init to create a new stack.yaml for the packages in the
current directory.
* If you want to use the project configuration at /home/username/.stack/global-project/stack.yaml, then you can add to its 'packages' field.
Configuring GHCi with the following packages:
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /tmp/haskell-stack-ghci/2a3bbd58/ghci-script
Prelude>
This means though that all you need to do to get the same behavior without the Note
is just start ghci manually in the context of global stack environment:
~$ stack exec -- ghci
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
Prelude>
In case that you want to make sure some package is installed for "playing around and learning" in the ghci session you can supply them as --package
arguments
~$ stack exec --package massiv -- ghci
atomic-primops> using precompiled package
cabal-doctest > using precompiled package
scheduler > using precompiled package
massiv > using precompiled package
Completed 4 action(s).
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
Prelude> import Data.Massiv.Array
Prelude Data.Massiv.Array>

lehins
- 9,642
- 2
- 35
- 49
0
stack exec --ghci
as in lehins's answer did not work for me, but stack exec ghci
did.

Alexander Kurz
- 178
- 7
-
It's not `exec --ghci`, it's `exec -- ghci`. – user1934428 Aug 24 '20 at 07:59
-
Indeed. Here `--` denotes the “end of options“ (except for `echo`). See [this explanation](https://www.devhowto.dev/cmdline/argument-syntax.html#end-of-options). – Fernando Basso Jul 01 '22 at 10:23