Home > Net >  How to handle following dependency conflict in Cabal?
How to handle following dependency conflict in Cabal?

Time:01-24

When I try to add scotty package to my multi-project cabal file, I get following dependency conflict. I am not exactly sure what it means.

harshal@Harshals-Linux hello-haskell % cabal build

Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: playground-0.1.0.0 (user goal)
[__1] trying: scotty-0.12.1 (dependency of playground)
[__2] trying: warp-3.3.23 (dependency of scotty)
[__3] trying: unix-compat-0.6 (dependency of warp)
[__4] trying: unix-2.7.3/installed-2.7.3 (dependency of warp)
[__5] next goal: directory (dependency of playground)
[__5] rejecting: directory-1.3.7.1/installed-1.3.7.1 (conflict: playground =>
directory>=1.3.8.0)
[__5] rejecting: directory-1.3.8.0 (conflict: unix==2.7.3/installed-2.7.3,
directory => unix>=2.8.0 && <2.9)
[__5] rejecting: directory-1.3.7.1 (conflict: playground =>
directory>=1.3.8.0)
[__5] skipping: directory-1.3.7.0, directory-1.3.6.2, directory-1.3.6.1,
directory-1.3.6.0, directory-1.3.5.0, directory-1.3.4.0, directory-1.3.3.2,
directory-1.3.3.1, directory-1.3.3.0, directory-1.3.2.2, directory-1.3.2.1,
directory-1.3.2.0, directory-1.3.1.5, directory-1.3.1.4, directory-1.3.1.3,
directory-1.3.1.2, directory-1.3.1.1, directory-1.3.1.0, directory-1.3.0.2,
directory-1.3.0.1, directory-1.3.0.0, directory-1.2.7.1, directory-1.2.7.0,
directory-1.2.6.3, directory-1.2.6.2, directory-1.2.5.1, directory-1.2.5.0,
directory-1.2.4.0, directory-1.2.3.1, directory-1.2.3.0, directory-1.2.2.1,
directory-1.2.2.0, directory-1.2.1.0, directory-1.2.0.1, directory-1.2.0.0,
directory-1.1.0.2, directory-1.1.0.1, directory-1.1.0.0, directory-1.0.1.2,
directory-1.0.1.1, directory-1.0.1.0, directory-1.0.0.3, directory-1.0.0.0,
directory-1.2.6.1 (has the same characteristics that caused the previous
version to fail: excluded by constraint '>=1.3.8.0' from 'playground')
[__5] fail (backjumping, conflict set: directory, playground, unix)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: directory, unix, playground,
unix-compat, warp, unix-compat:portable, scotty
Try running with --minimize-conflict-set to improve the error message.

How can I resolve this dependency conflict?

CodePudding user response:

What this says:

  • playground-0.1.0.0 depends on directory >= 1.3.8.0
  • directory-1.3.8.0 is the only apparent solution to directory >= 1.3.8.0
  • directory-1.3.8.0 depends on unix >= 2.8.0 && <2.9
  • we already committed to unix==2.7.3, which does not satisfy that constraint

One thing you could try, therefore, is to give it a hint that you want to pick a newer unix, by adding a top-level constraint:

% cabal build --build-depends `unix >=2.8.0 && <2.9`

Top-level constraints are "available" earlier than constraints found via searching for dependencies, and so can constrain earlier choices better. (I believe this property -- that constraints get solved and committed to in some not-totally-user-visible order -- is to make the dependency resolution algorithm more efficient. Bummer.)

  • Related