Reputation: 537
I came back to a project I hadn't worked on in a few weeks. In this time I have reinstalled stack. When I go to start GHCID by running ghcid -c 'stack exec -- ghci -isrc -iapp ~/haskell/fishing-web-app/app/Main.hs'
I get this error:
Could not find module ‘Base’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
8 | import qualified Base as B
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
What is strange though is that I can successfully compile and run my program with stack run
. I can also load Main.hs
into stack ghci
.
Base.hs
is located in the app
directory along with Main.hs
.
This is from my .cabal file to show that I have specified Base:
executable fishing-web-app-exe
main-is: Main.hs
other-modules:
Paths_fishing_web_app
, Base
...
At first I thought that the problem was the GHCID but I was able to reproduce the error message by running stack exec -- ghci -isrc -iapp ~/haskell/fishing-web-app/app/Main.hs
directly from the command line.
I also tried removing the .stack-work
directory and trying again but I got the same error.
The error message says to try to use the -v
flag to see the files searched for. Here is the output when I run ghcid -v 'stack exec ...
.
%ARCH: x86_64
%VERSION: 0.8.7
%ARGUMENTS: ["-v","stack exec -- ghci -isrc -iapp ~/haskell/fishing-web-app/app/Main.hs"]
Loading ghci -fno-code -fno-break-on-exception -fno-break-on-error -v1 -ferror-spans -j "stack exec -- ghci -isrc -iapp ~/haskell/fishing-web-app/app/Main.hs" ...
%STDOUT: GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
%STDOUT2: GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
%STDIN: import qualified System.IO as INTERNAL_GHCID
%STDIN: :unset +t +s
%STDIN: :set prompt #~GHCID-START~#
%STDIN: :set prompt-cont #~GHCID-START~#
%STDIN: :set -fno-break-on-exception
%STDIN: :set -fno-break-on-error
%STDIN: :set -v1
%STDIN: :set -fno-hide-source-paths
%STDIN:
INTERNAL_GHCID.putStrLn ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','1','~','#']
INTERNAL_GHCID.hPutStrLn INTERNAL_GHCID.stderr ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','1','~','#']
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
%STDERR:
%STDOUT2:
%STDERR: <no location info>: error:
%STDOUT2: <no location info>: error:
<no location info>: error:
%STDOUT: Failed, no modules loaded.
%STDERR: can't find file: stack exec -- ghci -isrc -iapp ~/haskell/fishing-web-app/app/Main.hs
%STDOUT2: Failed, no modules loaded.
%STDOUT2: can't find file: stack exec -- ghci -isrc -iapp ~/haskell/fishing-web-app/app/Main.hs
Failed, no modules loaded.
can't find file: stack exec -- ghci -isrc -iapp ~/haskell/fishing-web-app/app/Main.hs
%STDOUT: Prelude> Prelude> Prelude INTERNAL_GHCID> Prelude INTERNAL_GHCID> #~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-FINISH-1~#
%STDERR: #~GHCID-FINISH-1~#
%STDIN: :show modules
%STDIN:
INTERNAL_GHCID.putStrLn ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','2','~','#']
INTERNAL_GHCID.hPutStrLn INTERNAL_GHCID.stderr ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','2','~','#']
%STDOUT: #~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-FINISH-2~#
%STDERR: #~GHCID-FINISH-2~#
%STDIN:
%STDIN:
INTERNAL_GHCID.putStrLn ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','3','~','#']
INTERNAL_GHCID.hPutStrLn INTERNAL_GHCID.stderr ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','3','~','#']
%STDOUT: #~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-FINISH-3~#
%STDERR: #~GHCID-FINISH-3~#
%STDIN: :set -ferror-spans
:set -j
:set -fdiagnostics-color=always
%STDIN:
INTERNAL_GHCID.putStrLn ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','4','~','#']
INTERNAL_GHCID.hPutStrLn INTERNAL_GHCID.stderr ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','4','~','#']
%STDOUT: #~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-START~##~GHCID-FINISH-4~#
%STDERR: #~GHCID-FINISH-4~#
%STDIN: :show paths
%STDIN:
INTERNAL_GHCID.putStrLn ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','5','~','#']
INTERNAL_GHCID.hPutStrLn INTERNAL_GHCID.stderr ['#','~','G','H','C','I','D','-','F','I','N','I','S','H','-','5','~','#']
%STDOUT: #~GHCID-START~##~GHCID-START~#current working directory:
%STDOUT: /home/nick
%STDOUT: module import search paths:
%STDOUT: .
%STDOUT: #~GHCID-START~##~GHCID-START~##~GHCID-FINISH-5~#
%STDERR: #~GHCID-FINISH-5~#
%MESSAGES: [Message {loadSeverity = Error, loadFile = "/home/nick/<unknown>", loadFilePos = (0,0), loadFilePosEnd = (0,0), loadMessage = ["<no location info>: error:"," can't find file: stack exec -- ghci -isrc -iapp ~/haskell/fishing-web-app/app/Main.hs"]}]
%LOADED: ["/home/nick/<unknown>"]
]0;1 error - nick%WAITING: /home/nick/.ghcid /home/nick/<unknown>
%WAITING: /home/nick
My stack version is 2.5.1
Upvotes: 4
Views: 1721
Reputation: 537
The problem was that I was not running the stack exec
command from within the projects directory. If I run the command from within the app directory then everything works as expected.
Upvotes: 1