“无法加载软件包“ regex-posix”……未知符号“ regerror””

问题描述

对于一个新项目,我一直在尝试构建threepenny-gui软件包,这是我过去做过很多次而没有遇到任何麻烦的软件包。但是这次,我遇到了一条异常的错误消息:

> stack build
threepenny-gui     > configure
threepenny-gui     > Configuring threepenny-gui-0.9.0.0...
threepenny-gui     > build
threepenny-gui     > Preprocessing library for threepenny-gui-0.9.0.0..
threepenny-gui     > Building library for threepenny-gui-0.9.0.0..
threepenny-gui     > [ 1 of 29] Compiling Foreign.JavaScript.Include
threepenny-gui     > [ 2 of 29] Compiling Foreign.JavaScript.Resources
threepenny-gui     > ghc.exe: unable to load package `regex-posix-0.96.0.0'
threepenny-gui     > ghc.exe:  | C:\sr\snapshots\14724cfd\lib\x86_64-windows-ghc-8.8.4\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq\HSregex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq.o: unkNown symbol `regerror'

--  While building package threepenny-gui-0.9.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.0.1.0_ghc-8.8.4.exe --builddir=.stack-work\dist\29cc6475 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
Progress 1/2

现在,快速的Google显示错误消息 曾在2010年出现过,此后通过GHC更新对其进行了修复。我尝试更改GHC版本(上面的输出是GHC 8.8.4的结果),但它在8.8.3或8.8.2中均不起作用。我也尝试删除regex-posix¹,然后重新安装,但这也没有用。在这一点上,我必须承认这个错误完全困扰了我。其他人不知道可能是什么原因吗?如果是,我该如何解决

¹具体来说,我删除C:\sr\snapshots\14724cfd\lib\x86_64-windows-ghc-8.8.4\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuqC:\sr\snapshots\14724cfd\pkgdb\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq.conf,并做了ghc-pkg unregister regex-posix

解决方法

turned outregex-posix 而不是 threepenny-gui 中是一个问题。这个问题可以通过启用 Cabal 标志 _regex-posix-clib 来解决。要设置它,我首先需要注销以前版本的 regex-posix

> stack --resolver lts-16.23 exec -- ghc-pkg unregister regex-posix-0.96.0.0 --force

然后我需要用正确的标志重建它:

> stack build regex-posix-0.96.0.0 --flag regex-posix:_regex-posix-clib --resolver lts-16.23

之后 stack build threepenny-gui --resolver lts-16.23 成功。 (出于某种原因,我需要在这些命令中明确指定解析器。)