Domanda

I've got the following question:

I've got two Haskell libraries that depend on each other, and both libraries are managed by cabal. The corresponding cabal files look like this:

Library 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:   <...>

Library 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: <...>

Installing one of the libraries (here library 2) with cabal install works:

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...

But trying to install the other library (here library 1) with cabal install results in a dependency error:

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)

Is there any way to handle two such libraries that depend on each other so that I don't get dependency errors or is cabal simply not able to handle such a case properly?

È stato utile?

Soluzione

As the others have said, circular dependencies are never going to work in Cabal. It's hard enough to compile modules with circular dependencies, but packages are a hopeless cause.

It can be annoyingly difficult sometimes, but the only real solution is to find a way to break the circular dependency somehow.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top