Cabal install 忽略 build-depends 中的包然后请求它

Cabal install ignores a package in build-depends and then requests for it

使用 cabal 我正在尝试安装 iserv-proxy,它的构建取决于 libiserv,我之前已经安装过它。当我发出安装命令时:

ghc/utils/iserv-proxy$ cabal install -flibrary -fproxy

它失败了:

src/Main.hs:53:1: error:
Could not load module `Remote.Message'
It is a member of the hidden package `libiserv-8.6.3'.
Perhaps you need to add `libiserv' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
   |
53 | import Remote.Message
   | ^^^^^^^^^^^^^^^^^^^^^

如错误所述,Remote.Messagelibiserv 中的 exposed-module,但 libiserv 存在于 iserv-proxy.cabal 文件的构建依赖项中,就像 8.6.3 版本的 ghc:
(只是我将 containers 上层依赖项从 0.6 更改为 0.7,这造成了依赖项冲突。)

iserv-proxy.cabal:

.
.
.
Executable iserv-proxy
Default-Language: Haskell2010
Main-Is: Main.hs
Hs-Source-Dirs: src 
Build-Depends: array      >= 0.5 && < 0.6,
               base       >= 4   && < 5,
               binary     >= 0.7 && < 0.9,
               bytestring >= 0.10 && < 0.11,
               containers >= 0.5 && < 0.7,
               deepseq    >= 1.4 && < 1.5,
               directory  >= 1.3 && < 1.4,
               network    >= 2.6,
               filepath   >= 1.4 && < 1.5,
               ghci       == 8.6.*,
               libiserv   == 8.6.*

cabal 知道 libiserv 安装:

$ cabal list --installed libiserv
* libiserv
    Default available version: [ Not available from any configured repository ]
    Installed versions: 8.6.3
    License:  BSD-3-Clause

build-depends,因为它在详细的安装日志 (-v) 中显示,您可以在 pastebin.

中找到它

太奇怪了,我对 cabalghc 还很陌生,所以我可能搞砸了。当我查看上面 verbose log:

中的 ghc 命令时
/opt/ghc/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir dist/build/iserv-proxy/iserv-proxy-tmp -odir dist/build/iserv-proxy/iserv-proxy-tmp -hidir dist/build/iserv-proxy/iserv-proxy-tmp -stubdir dist/build/iserv-proxy/iserv-proxy-tmp -i -idist/build/iserv-proxy/iserv-proxy-tmp -isrc -idist/build/iserv-proxy/autogen -idist/build/global-autogen -Idist/build/iserv-proxy/autogen -Idist/build/global-autogen -Idist/build/iserv-proxy/iserv-proxy-tmp -optP-include -optPdist/build/iserv-proxy/autogen/cabal_macros.h -hide-all-packages -Wmissing-home-modules -package-db dist/package.conf.inplace -package-id array-0.5.3.0 -package-id base-4.12.0.0 -package-id binary-0.8.6.0 -package-id bytestring-0.10.8.2 -package-id containers-0.6.0.1 -package-id deepseq-1.4.4.0 -package-id directory-1.3.3.0 -package-id filepath-1.4.2.1 -package-id ghci-8.6.3 -package-id libiserv-8.6.3 -package-id network-2.8.0.0-AkCJm1aNSYz7ekXKYyI0pF -XHaskell2010 src/Main.hs

它缺少任何 -I-includelibiserv 库,有趣的是 libiserv 安装没有任何 .h 文件或 include目录:

$ ls /root/.cabal/lib/x86_64-linux-ghc-8.6.3/libiserv-8.6.3-EjLBkFaay9bH1Xm2bkeUPB/
GHCi  Lib.dyn_hi  Lib.hi  Remote  libHSlibiserv-8.6.3-EjLBkFaay9bH1Xm2bkeUPB.a

我的配置:

$ cabal --version
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library 
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.3
ghc$ git log -1
Author: Ben Gamari <ben@smart-cactus.org>
Date:   Thu Dec 6 16:58:34 2018 -0500

    Release 8.6.3

我的 ghc-pkg check returns 几个关于 haddock-htmlhaddock-interfaces 文件的警告丢失了。您可能会在另一个 pastebin

中找到完整的输出

更新:

在安装命令中添加 --ghc-options="-i../../libraries/libiserv/src/" 解决了我的问题,但它不应该是那样的,所以我打开这个问题,寻找更好的解决方案。

请注意,libiserv 可以构建 网络支持,也可以不支持。默认情况下,它将在没有的情况下构建。您需要使用 -fnetwork 构建 libiserv 才能公开 Remote.Message.

因此你可能想要这样的东西:

libiserv $ cabal install -fnetwork
iserv-proxy $ cabal install -flibrary -fproxy