I'm getting an error when attempting to compile Haskell tests using test-framework on Windows.
Steps to reproduce
Create a new library using Stack:
$ stack new repro simple-library
Then navigate into the repro
directory and edit the repro.cabal
file by adding test-framework
to build-depends
:
library
hs-source-dirs: src
exposed-modules: Lib
build-depends: base >= 4.7 && < 5,
test-framework
default-language: Haskell2010
Now attempt to compile the library:
$ stack build
Expected outcome
The code compiles
Actual outcome
Compilation fails with this error message:
$ 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
How do I resolve this error?
Environment
$ stack --version
Version 2.7.3, Git revision 7927a3aec32e2b2e5e4fb5be76d0d50eddcc197f x86_64 hpack-0.34.4
Windows
Edition Windows 10 Pro
Version 21H1
Installed on 14.09.2020
OS build 19043.1348
Experience Windows Feature Experience Pack 120.2212.3920.0
CodePudding user response:
I assume, given when you posted this question, you are using LTS 18.17. Looking at that LTS, it uses mintty 0.1.3. Looking in mintty 0.1.3's cabal file shows a special flag that is enabled by default that means that System.Console.MinTTY.Win32
is not included. The comments in that cabal file say that that flag should be used when using Win32 2.13.1.0 or newer.
However, when I look at LTS 18's configuration in Stackage, I can see that it is using Win32 2.6.2.1, so that flag ought to be set to false for this package to work.
So let's check that in the Stackage build constraints. I see that another flag is being set, and it seems to be an old flag that is no longer used (looks like it was used in an older 0.1.2 version). This must be the problem.
The solution: manually set the flag in your stack.yaml:
flags:
mintty:
Win32-2-13-1: false