当我试图在Windows上使用test-framework编译Haskell测试时,我得到了一个错误。
复制步骤
使用Stack创建一个新库:
$ stack new repro simple-library然后导航到repro目录,并通过将test-framework添加到build-depends来编辑repro.cabal文件
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窗口
Edition Windows 10 Pro
Version 21H1
Installed on 14.09.2020
OS build 19043.1348
Experience Windows Feature Experience Pack 120.2212.3920.0发布于 2021-11-20 14:21:31
我假设,当您发布这个问题时,您使用的是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中查看LTS18的配置时,我可以看到它正在使用Win32 2.6.2.1,因此应该将该标志设置为false才能使这个包工作。
因此,让我们在堆栈构建约束中检查这一点。我看到正在设置another flag,这似乎是一个不再使用的旧标志(看起来像是在older 0.1.2 version中使用的)。这一定是问题所在。
解决方案:在stack.yaml中手动设置标志:
flags:
mintty:
Win32-2-13-1: falsehttps://stackoverflow.com/questions/70045586
复制相似问题