Skip to content
Latchkey

Elixir/Hex "no matching version" in CI

Hex’s resolver could not find versions that satisfy every requirement in mix.exs. Two dependencies pin incompatible versions of a shared package, so no consistent set exists.

What this error means

mix deps.get fails reporting that it failed to use a package "because ... no matching version", listing the conflicting requirements. It is deterministic and reproduces with the same mix.exs/mix.lock.

mix output
Resolving Hex dependencies...
** (Mix) Hex dependency resolution failed, retry with --verbose.

Failed to use "jason" (version 1.4.0) because
  app (mix.exs) requires ~> 1.2
  other_lib (version 0.9.0) requires ~> 1.0 and <= 1.3.0

Common causes

Conflicting version requirements

Two dependencies require non-overlapping versions of a shared Hex package, so the resolver cannot pick one that satisfies both.

An over-tight requirement in mix.exs

A narrow ==/~> requirement you added conflicts with what a dependency needs; loosening it to an overlapping range often resolves it.

How to fix it

Inspect the conflict verbosely

Re-run with --verbose to see every constraint involved.

Terminal
mix deps.get --verbose

Relax or align the requirement

  1. Find the shared package and the two conflicting requirements.
  2. Loosen your own requirement to a range that overlaps both.
  3. If two third-party deps conflict, upgrade the lagging one to a release that accepts the newer shared dependency.

Lock and commit the resolved set

Terminal
mix deps.get
git add mix.lock && git commit -m "Update mix.lock"

How to prevent it

  • Commit mix.lock so CI installs the resolved versions.
  • Use ranges (~>) rather than hard == pins where possible.
  • Upgrade related dependencies together to keep shared deps compatible.

Related guides

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