Skip to content
Latchkey

Elixir "protocol has not been consolidated" warning in CI

Elixir consolidates protocols at compile time for speed. A "has not been consolidated" warning (or a Protocol.UndefinedError) in CI usually means a stale _build was restored and a newly added implementation was not re-consolidated.

What this error means

CI logs "warning: the protocol Enumerable has not been consolidated" or a test fails with "** (Protocol.UndefinedError) protocol X not implemented for ...".

** (Protocol.UndefinedError)
warning: the protocol Jason.Encoder has not been consolidated
** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for %MyApp.Money{}

Common causes

Stale consolidated protocols in a restored _build

A cached _build holds consolidated beams from before your new implementation existed, so the impl is not registered.

Consolidation disabled or partial in the compile step

A compile that skipped consolidation, or mixed environments, leaves protocols un-consolidated at runtime.

How to fix it

Force a clean compile so protocols re-consolidate

  1. Clear stale build artifacts and recompile.
  2. Ensure the cache key changes when Elixir/OTP or deps change.
  3. Re-run so the new implementation is consolidated.
Terminal
mix clean
mix compile

Key the _build cache correctly

Include OTP/Elixir versions and mix.lock in the _build cache key so a fresh consolidation happens after relevant changes.

.github/workflows/ci.yml
key: build-${{ runner.os }}-otp${{ steps.beam.outputs.otp-version }}-${{ hashFiles('**/mix.lock') }}

How to prevent it

  • Include toolchain and lock hashes in the _build cache key.
  • Recompile cleanly when protocol implementations change.
  • Avoid sharing _build caches across different environments.

Frequently asked questions

What causes ""protocol ... has not been consolidated""?
A cached _build holds consolidated beams from before your new implementation existed, so the impl is not registered.
How do I fix "protocol ... has not been consolidated"?
Force a clean compile so protocols re-consolidate

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card