Cabal error: At least the following dependencies are missing:

Cabal error: At least the following dependencies are missing:

我正在尝试使用 HUnit 为我的 Haskell/Cabal 包创建一个测试套件,并且在我 运行 cabal 测试时出现以下错误:

matthew@matthew-Gnawty:~/backup/projects/apollo$ cabal test
Re-configuring with test suites enabled. If this fails, please run configure
manually.
Resolving dependencies...
Configuring apollo-0.1.0.0...
cabal: At least the following dependencies are missing:
hunit >=1.2 && <1.4

我有 运行 'cabal hunit' 来安装 hunit。要检查它是否已安装,我有 运行 "ghc-pkg list HUnit" 其中 returns:

matthew@matthew-Gnawty:~/backup/projects/apollo$ ghc-pkg list HUnit
/var/lib/ghc/package.conf.d
   HUnit-1.2.5.2
/home/matthew/.ghc/x86_64-linux-7.6.3/package.conf.d
   HUnit-1.3.1.1

为什么 cabal 无法正确配置?


我试过:

为了确保 cabal 注意到全局 (1.2.5.2) 版本或本地 (1.3.1.1) 版本,方法是将 build-depends 指定为:

build-depends: base >=4.6 && <4.7,
               hunit >=1.2 && <1.4

在我的 [packagename].cabal 文件中。

我也注意到了https://www.haskell.org/cabal/FAQ.html#runghc-setup-complains-of-missing-packages,但不明白那里给出的解释,以及Setup.hs是如何相关的。

我的 Setup.hs 文件仅包含

import Distribution.Simple
main = defaultMain

我尝试将 'import Test.HUnit' 添加到 Setup.hs 文件:

import Distribution.Simple
import Test.HUnit
main = defaultMain

运行ning 'cabal test' 与此 Setup.hs 给出相同的错误。

这个问题似乎可以通过将 hunit 大写为 HUnit 来解决,即更改

build-depends: base >=4.6 && <4.7,
               hunit >=1.2 && <1.4

build-depends: base >=4.6 && <4.7,
               HUnit >=1.2 && <1.4