嘗試在 Windows 上使用測驗框架編譯 Haskell 測驗時出現錯誤。
重現步驟
使用 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
視窗
Edition Windows 10 Pro
Version 21H1
Installed on ?14.?09.?2020
OS build 19043.1348
Experience Windows Feature Experience Pack 120.2212.3920.0
uj5u.com熱心網友回復:
我假設,當您發布此問題時,您使用的是 LTS 18.17。看看那個 LTS,它使用mintty 0.1.3。展望mintty 0.1.3的陰謀檔案顯示一個特殊的標志即是默認認為它的意思啟用的System.Console.MinTTY.Win32是不包括在內。該 cabal 檔案中的注釋說,在使用 Win32 2.13.1.0 或更新版本時應使用該標志。
但是,當我在 Stackage 中查看 LTS 18 的配置時,我可以看到它使用的是Win32 2.6.2.1,因此該標志應該設定為 false 才能使該包正常作業。
所以讓我們在 Stackage 構建約束中檢查一下。我看到正在設定另一個標志,它似乎是一個不再使用的舊標志(看起來它是在較舊的 0.1.2 版本中使用的)。這一定是問題所在。
解決方案:在 stack.yaml 中手動設定標志:
flags:
mintty:
Win32-2-13-1: false
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/363871.html
上一篇:為這個資料型別定義一個函子實體
下一篇:使用匿名函式折疊
