简体   繁体   中英

stack ghci not loading up local modules?

I have

mainLogger.hs
Logger.hs

in my local directory where the mainLogger.hs reference the Logger module.

When in stack ghci I :load mainLogger.hs I get the following error message :

mainLogger.hs:6:18:
    Could not find module ‘Logger’
    It is not a module in the current program, or in any known package.

However if I can compile stack exec -- ghc mainLogger.hs and run stack runghc mainLogger2.hs or have stack exec -- ghci load the module correctly.

Anyone knows what is preventing stack ghci from locating module in the local directory ?

ps : I am not using any cabal file or stack.yaml file in this directory, so it falls back onto my global stack.yaml config

You should be able to load both if you do it at the same time:

:load Logger.hs mainLogger.hs 

I don't know if you can get GHCi to look for the missing module in the current folder if you have no cabal file but if you create/initialize one this is not necessary.

This issue should now be fixed in the latest version of stack. It seems that when a module imported a local module, stack wasn't including the local directory in its module search path. In the latest 1.5.1. version of stack, this has been fixed - so you should be able to just type

stack ghci mainLogger.hs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM