Confusing Elixir Errors
October 7, 2020
2 minute read

TL;DR

Fixing Elixir Errors that Make No Sense

I spent the last ~day of side project time being confused by errors that made no sense like:

Can't compile hackney?!

Other mindbending erros that made no sense included:

  • (Mix) Could not find a Mix.Project, please ensure a mix.exs file is available
  • (Mix) Could not compile dependency :elixir_make

Often these did not include an error message at all, or included error messages like erlang complaining about ===> Uncaught error: {badmatch,[]} when trying to compile a dependency.

Your Problem Is Rebar & Mix

Elixir is built on top of erlang and each version of elixir is designed to work with a particular version of erlang (and OTP).

What first caused my problem was that I upgraded elixir to 1.10 (and then 1.11) but I didn’t change the version of mix (and the cached copies of rebar3 & rebar Mix uses to build erlang code). Then I compounded that problem by using brew to install an independent copy of rebar that was, I think, sometimes getting used because it was on $PATH and would get picked up by scripts.

The fix

First try these two commands:

mix local.hex 
mix local.rebar

This will replace your local cached hex and rebar with whatever version your installed version of elixir wants. If this fails, try uninstalling elixir and erlang entirely and reinstalling them.