使用 Stack 构建包 regex-posix-0.96.0.0 时出错
Error building package regex-posix-0.96.0.0 with Stack
我正在尝试使用 Stack 编译一个新的 Haskell 项目,但我收到此错误消息:
$ stack build
WARNING: Ignoring regex-posix's bounds on base (<0 && >=4.3 && <4.16); using base-4.14.1.0.
Reason: trusting snapshot over cabal file dependency information.
regex-posix > configure
regex-posix > Configuring regex-posix-0.96.0.0...
regex-posix > build
regex-posix > Preprocessing library for regex-posix-0.96.0.0..
regex-posix > compiling .stack-work\dist4b403a\build\Text\Regex\Posix\Wrap_hsc_make.c failed (exit code 1)
regex-posix > rsp file was: ".stack-work\dist\274b403a\build\Text\Regex\Posix\hsc5BFC.rsp"
regex-posix > command was: C:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\../mingw/bin\gcc.exe -c .stack-work\dist4b403a\build\Text\Regex\Posix\Wrap_hsc_make.c -o .stack-work\dist4b403a\build\Text\Regex\Posix\Wrap_hsc_make.o -D__GLASGOW_HASKELL__=810 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Icbits -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -I.stack-work\dist4b403a\build\cbits -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -I.stack-work\dist4b403a\build\autogen -I.stack-work\dist4b403a\build\global-autogen -include .stack-work\dist4b403a\build\autogen\cabal_macros.h -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\bytestring-0.10.12.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\base-4.14.1.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\integer-gmp-1.0.3.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib/include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4/lib/include/
regex-posix > error: Wrap.hsc:96:10: fatal error: regex.h: No such file or directory
regex-posix > compilation terminated.
regex-posix >
Progress 1/2
-- While building package regex-posix-0.96.0.0 (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.4.exe --builddir=.stack-work\dist4b403a build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
我不明白最初的警告。在查看 regex-posix package 的依赖项时,它确实将 base (>=4.3 && <4.16)
列为依赖项,但是 <0
来自哪里?
我在 stack.yaml
中将解析器设置为 LTS 18.0:
resolver: lts-18.0
根据documentation of LTS 18.0,它使用base-4.14.1.0
。如果版本控制是字典序的,我认为 4.14.1.0 符合 regex-posix 要求的范围(如果我们暂时忽略奇怪的 <0
约束)。
以下是我的package.yaml
的相关部分:
dependencies:
- base >= 4.7 && < 5
- regex-posix >= 0.96
library:
source-dirs: src
ghc-options:
- -Wall
我的stack
版本:
$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4
我在 Windows 10.
FWIW,我并不是很关心 regex-posix 本身。实际上,我正在尝试设置一个测试项目,并且 test-framework 取决于 regex-posix.
如何解决这个问题以便我可以编译我的代码?
错误与版本无关,这只是一个警告。真正的错误是关于底层 C 库缺少“regex.h”header。 header 几乎总是出现在 posix 平台上(比如 linux),但不出现在 Windows 上。参见 https://github.com/haskell-hvr/regex-posix/issues/4
特别是 Paul Johnson 的 this comment:
Correction to the above: you don't need mingw64. You just need to install with the _regex-posix-clib flag enabled (note the underscore).
With plain cabal: cabal install regex-posix -f _regex-posix-clib
In Stack, add the following to your stack.yaml:
extra-deps:
- regex-posix-clib-2.7
flags:
regex-posix:
_regex-posix-clib: true
在该线程中还有关于 <0
版本的评论:https://github.com/haskell-hvr/regex-posix/issues/4#issuecomment-699786233
我正在尝试使用 Stack 编译一个新的 Haskell 项目,但我收到此错误消息:
$ stack build
WARNING: Ignoring regex-posix's bounds on base (<0 && >=4.3 && <4.16); using base-4.14.1.0.
Reason: trusting snapshot over cabal file dependency information.
regex-posix > configure
regex-posix > Configuring regex-posix-0.96.0.0...
regex-posix > build
regex-posix > Preprocessing library for regex-posix-0.96.0.0..
regex-posix > compiling .stack-work\dist4b403a\build\Text\Regex\Posix\Wrap_hsc_make.c failed (exit code 1)
regex-posix > rsp file was: ".stack-work\dist\274b403a\build\Text\Regex\Posix\hsc5BFC.rsp"
regex-posix > command was: C:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\../mingw/bin\gcc.exe -c .stack-work\dist4b403a\build\Text\Regex\Posix\Wrap_hsc_make.c -o .stack-work\dist4b403a\build\Text\Regex\Posix\Wrap_hsc_make.o -D__GLASGOW_HASKELL__=810 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Icbits -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -I.stack-work\dist4b403a\build\cbits -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -I.stack-work\dist4b403a\build\autogen -I.stack-work\dist4b403a\build\global-autogen -include .stack-work\dist4b403a\build\autogen\cabal_macros.h -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\bytestring-0.10.12.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\base-4.14.1.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\integer-gmp-1.0.3.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib/include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4/lib/include/
regex-posix > error: Wrap.hsc:96:10: fatal error: regex.h: No such file or directory
regex-posix > compilation terminated.
regex-posix >
Progress 1/2
-- While building package regex-posix-0.96.0.0 (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.4.exe --builddir=.stack-work\dist4b403a build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
我不明白最初的警告。在查看 regex-posix package 的依赖项时,它确实将 base (>=4.3 && <4.16)
列为依赖项,但是 <0
来自哪里?
我在 stack.yaml
中将解析器设置为 LTS 18.0:
resolver: lts-18.0
根据documentation of LTS 18.0,它使用base-4.14.1.0
。如果版本控制是字典序的,我认为 4.14.1.0 符合 regex-posix 要求的范围(如果我们暂时忽略奇怪的 <0
约束)。
以下是我的package.yaml
的相关部分:
dependencies:
- base >= 4.7 && < 5
- regex-posix >= 0.96
library:
source-dirs: src
ghc-options:
- -Wall
我的stack
版本:
$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4
我在 Windows 10.
FWIW,我并不是很关心 regex-posix 本身。实际上,我正在尝试设置一个测试项目,并且 test-framework 取决于 regex-posix.
如何解决这个问题以便我可以编译我的代码?
错误与版本无关,这只是一个警告。真正的错误是关于底层 C 库缺少“regex.h”header。 header 几乎总是出现在 posix 平台上(比如 linux),但不出现在 Windows 上。参见 https://github.com/haskell-hvr/regex-posix/issues/4
特别是 Paul Johnson 的 this comment:
Correction to the above: you don't need mingw64. You just need to install with the _regex-posix-clib flag enabled (note the underscore).
With plain cabal: cabal install regex-posix -f _regex-posix-clib
In Stack, add the following to your stack.yaml:
extra-deps: - regex-posix-clib-2.7 flags: regex-posix: _regex-posix-clib: true
在该线程中还有关于 <0
版本的评论:https://github.com/haskell-hvr/regex-posix/issues/4#issuecomment-699786233