Haskell cabal "Could not resolve dependencies" in CI
cabal ran its dependency solver and could not find a consistent set of package versions that satisfies every constraint. It prints "Could not resolve dependencies" and the rejecting reasons that blocked each candidate.
What this error means
cabal build or cabal freeze fails with "Could not resolve dependencies" followed by "rejecting: X-1.2 (conflict: ...)" lines naming the constraints that collide.
Error: cabal: Could not resolve dependencies:
[__0] trying: myapp-0.1.0.0 (user goal)
[__1] next goal: aeson (dependency of myapp)
[__1] rejecting: aeson-2.2.1.0 (conflict: myapp => aeson<2.0)
[__1] fail (backjumping, conflict set: aeson, myapp)Common causes
A constraint conflicts with available versions
A version bound in build-depends excludes every version of a package that other constraints require, so no plan exists.
An outdated package index or stale freeze file
A stale index or cabal.project.freeze pins versions that no longer resolve together.
How to fix it
Update the index and relax the bound
- Run
cabal updateso the solver sees the latest Hackage index. - Read the rejecting/conflict lines and widen the over-tight bound.
- Re-run
cabal buildto confirm a plan resolves.
cabal update
cabal build allLoosen the version constraint
Widen the build-depends bound so a version that satisfies all constraints is allowed.
build-depends: base >=4.14, aeson >=2.0 && <3How to prevent it
- Run
cabal updatebefore resolving in CI. - Keep version bounds wide enough to admit compatible releases.
- Regenerate the freeze file when bounds change.