Skip to content
Latchkey

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.

Haskell
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

  1. Run cabal update so the solver sees the latest Hackage index.
  2. Read the rejecting/conflict lines and widen the over-tight bound.
  3. Re-run cabal build to confirm a plan resolves.
Terminal
cabal update
cabal build all

Loosen the version constraint

Widen the build-depends bound so a version that satisfies all constraints is allowed.

app.cabal
build-depends: base >=4.14, aeson >=2.0 && <3

How to prevent it

  • Run cabal update before resolving in CI.
  • Keep version bounds wide enough to admit compatible releases.
  • Regenerate the freeze file when bounds change.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →