构建 lib 时 cabal 安装出错

Error with cabal install while building lib

我正在尝试使用 cabal install --allow-newer=all FunGEn 安装 FunGEn(我添加了 --allow-newer=all 因为它在依赖项方面有问题)。在 运行 几次尝试后,我不断收到相同的错误消息:

Resolving dependencies...
Build profile: -w ghc-9.2.1 -O1
In order, the following will be built (use -v for more details):
 - text-1.2.3.2 (lib) (requires build)
 - OpenGLRaw-3.3.4.1 (lib) (requires build)
 - GLURaw-2.0.0.5 (lib) (requires build)
 - OpenGL-3.0.3.0 (lib) (requires build)
 - GLUT-2.7.0.16 (lib) (requires build)
 - FunGEn-1.1.1 (lib) (requires build)
 - FunGEn-1.1.1 (exe:fungen-worms) (requires build)
 - FunGEn-1.1.1 (exe:fungen-hello) (requires build)
 - FunGEn-1.1.1 (exe:fungen-pong) (requires build)
Starting     text-1.2.3.2 (lib)
Building     text-1.2.3.2 (lib)

Failed to build text-1.2.3.2.
Build log (
C:\cabal\logs\ghc-9.2.1\text-1.2.3.2-69443a9a6ed6dc92878e4d67ead16d149c2e752e.log
):
Preprocessing library for text-1.2.3.2..
Building library for text-1.2.3.2..
[ 1 of 44] Compiling Data.Text.Encoding.Error ( Data\Text\Encoding\Error.hs, dist\build\Data\Text\Encoding\Error.o )
[ 2 of 44] Compiling Data.Text.Internal.Builder.Int.Digits ( Data\Text\Internal\Builder\Int\Digits.hs, dist\build\Data\Text\Internal\Builder\Int\Digits.o )
[ 3 of 44] Compiling Data.Text.Internal.Builder.RealFloat.Functions ( Data\Text\Internal\Builder\RealFloat\Functions.hs, dist\build\Data\Text\Internal\Builder\RealFloat\Functions.o )
[ 4 of 44] Compiling Data.Text.Internal.Encoding.Utf16 ( Data\Text\Internal\Encoding\Utf16.hs, dist\build\Data\Text\Internal\Encoding\Utf16.o )

Data\Text\Internal\Encoding\Utf16.hs:32:23: error:
    * Couldn't match expected type `Word#' with actual type `Word16#'
    * In the first argument of `word2Int#', namely `a#'
      In the expression: word2Int# a#
      In an equation for `x#': !x# = word2Int# a#
   |
32 |       !x# = word2Int# a#
   |                       ^^

Data\Text\Internal\Encoding\Utf16.hs:33:23: error:
    * Couldn't match expected type `Word#' with actual type `Word16#'
    * In the first argument of `word2Int#', namely `b#'
      In the expression: word2Int# b#
      In an equation for `y#': !y# = word2Int# b#
   |
33 |       !y# = word2Int# b#
   |                       ^^
cabal.exe: Failed to build text-1.2.3.2 (which is required by exe:fungen-worms
from FunGEn-1.1.1, exe:fungen-hello from FunGEn-1.1.1 and others). See the
build log above for details.

有人可以解释这里出了什么问题,以及可能的解决方法吗?谢谢!

这些特定错误是由于使用 GHC 9.2 编译与 GHC 9.2 不兼容的代码所致。您尝试使用的包可以与 GHC 9.0 一起编译(不需要 --allow-newer),我建议您使用它。现在使用 GHCup.

在编译器版本之间切换非常容易

另一个不需要切换编译器的选项是,就像您所做的那样,以某种方式应用 --alow-newer 。您应该明白,它是一种非常危险的武器,只有在您了解依赖项解决的工作原理,并且有足够的经验和 cabal 一般情况下才能更好地使用它。对我有用的变体:

cabal update
cabal install --allow-newer=bytestring FunGEn

您的方法中的另一个可能问题是 cabal install(上面没有适当的开关)只会为您提供包中的可执行文件,而不是库中的可执行文件。如果那是你想要的也没关系。