我有以下问题:
我有两个相互依赖的Haskell库,这两个库都是由cabal管理的。相应的cabal文件如下所示:
图书馆1:
name: Lib1
version: 0.1
cabal-version: >=1.2
build-type: Simple
author: Matthias
library
hs-source-dirs: src
build-depends:
base >= 4,
Lib2
ghc-options: -Wall
exposed-modules: <...>
图书馆2:
name: Lib2
version: 0.1
cabal-version: >=1.2
build-type: Simple
author: Matthias
library
hs-source-dirs: src
build-depends:
base >= 4,
Lib1
ghc-options: -Wall
exposed-modules: <...>
使用cabal install
安装其中一个库(此处为库2):
Resolving dependencies...
In order, the following will be installed:
Lib2-0.1 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Configuring Lib2-0.1...
Building Lib2-0.1...
Preprocessing library Lib2-0.1...
Registering Lib2-0.1...
Installing library in
C:\Users\Matthias\AppData\Roaming\cabal\Lib2-0.1\ghc-7.4.2
Registering Lib2-0.1...
但是尝试使用cabal install
安装其他库(此处为库1)会导致依赖性错误:
Resolving dependencies...
cabal.exe: Could not resolve dependencies:
trying: Lib1-0.1 (user goal)
next goal: Lib2 (dependency of Lib1-0.1)
rejecting: Lib2-0.1/installed-aa4... (package is broken)
有没有办法处理两个相互依赖的库,这样我就不会出现依赖性错误,或者只是无法正确处理这种情况?
答案 0 :(得分:5)
正如其他人所说,循环依赖永远不会在Cabal中起作用。使用循环依赖项编译 modules 是很困难的,但 packages 是一个无望的原因。
有时可能会非常困难,但唯一真正的解决方案是找到一种方法来以某种方式打破循环依赖。