尝试使用 test-framework 编译 Haskell 测试时出现错误在 Windows 上。
重现步骤
使用 Stack 创建一个新库:
$ stack new repro simple-library
然后导航到 repro
目录并编辑repro.cabal
通过添加 test-framework
文件至build-depends
:library
hs-source-dirs: src
exposed-modules: Lib
build-depends: base >= 4.7 && < 5,
test-framework
default-language: Haskell2010
现在尝试编译库:$ stack build
预期结果代码编译
实际结果
编译失败并显示以下错误消息:
$ stack build
WARNING: Ignoring mintty's bounds on Win32 (>=2.13.1); using Win32-2.6.2.1.
Reason: trusting snapshot over cabal file dependency information.
mintty > configure
mintty > Configuring mintty-0.1.3...
mintty > build
mintty > Preprocessing library for mintty-0.1.3..
mintty > Building library for mintty-0.1.3..
mintty > [1 of 1] Compiling System.Console.MinTTY
mintty >
mintty > src\System\Console\MinTTY.hs:31:1: error:
mintty > Could not find module `System.Console.MinTTY.Win32'
mintty > Use -v (or `:set -v` in ghci) to see a list of the files searched for.
mintty > |
mintty > 31 | import qualified System.Console.MinTTY.Win32 as Win32 (isMinTTY, isMinTTYHandle)
mintty > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mintty >
Progress 1/5
-- While building package mintty-0.1.3 (scroll up to its section to see the error) using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.2.1.0_ghc-8.10.7.exe --builddir=.stack-work\dist\274b403a build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
如何解决此错误?环境
$ stack --version
Version 2.7.3, Git revision 7927a3aec32e2b2e5e4fb5be76d0d50eddcc197f x86_64 hpack-0.34.4
window Edition Windows 10 Pro
Version 21H1
Installed on 14.09.2020
OS build 19043.1348
Experience Windows Feature Experience Pack 120.2212.3920.0
最佳答案
我假设,当您发布此问题时,您使用的是 LTS 18.17。查看那个 LTS,它使用 mintty 0.1.3 .查看 mintty 0.1.3 的 cabal 文件显示 special flag默认启用,这意味着 System.Console.MinTTY.Win32
是 not included .该 cabal 文件中的注释说,在使用 Win32 2.13.1.0 或更高版本时应该使用该标志。
但是,当我在 Stackage 中查看 LTS 18 的配置时,我可以看到它正在使用 Win32 2.6.2.1 ,因此该标志应该设置为 false 才能使此包正常工作。
所以让我们在 Stackage 构建约束中检查一下。我看到 another flag正在设置,它似乎是一个不再使用的旧标志(看起来像是在 older 0.1.2 version 中使用过)。这一定是问题所在。
解决方案:在你的 stack.yaml 中手动设置标志:
flags:
mintty:
Win32-2-13-1: false
关于haskell - 在 Windows 上使用 Stack 编译测试框架时找不到模块 System.Console.MinTTY.Win32,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70045586/