[英]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. 在我的本地目录中,mainLogger.hs引用Logger模块。
When in stack ghci
I :load mainLogger.hs
I get the following error message : 在
stack ghci
我:load mainLogger.hs
我收到以下错误信息:
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. 但是,如果我可以编译
stack exec -- ghc mainLogger.hs
并运行stack runghc mainLogger2.hs
或者stack exec -- ghci
正确加载模块。
Anyone knows what is preventing stack ghci
from locating module in the local directory ? 任何人都知道什么阻止
stack ghci
在本地目录中找到模块?
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 ps:我没有在这个目录中使用任何cabal文件或stack.yaml文件,所以它回到我的全局stack.yaml配置
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. 我不知道如果你没有cabal文件,你是否可以让GHCi在当前文件夹中查找丢失的模块,但是如果你创建/初始化一个,则没有必要这样做。
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.
在最新的1.5.1。 version of stack, this has been fixed - so you should be able to just type
堆栈的版本,这已经修复 - 所以你应该只能键入
stack ghci mainLogger.hs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.