Walt Stoneburner's Ramblings

Currating Chaos

(Elixir) Could not find Hex

When performing a mix deps.get command for an Elixir application, I got this prompt and error message regarding the Hex Package Manager:

Could not find Hex, which is needed to build dependency :dep_from_hexpm
Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] 

16:43:44.371 [error] Task #PID<0.105.0> started from #PID<0.92.0> terminating
** (UndefinedFunctionError) function :inets.stop/2 is undefined (module :inets is not available)
    :inets.stop(:httpc, :mix)
    (mix) lib/mix/utils.ex:578: Mix.Utils.read_httpc/1
    (mix) lib/mix/utils.ex:526: anonymous fn/2 in Mix.Utils.read_path/2
    (elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: #Function<4.48707297/0 in Mix.Utils.read_path/2>
    Args: []
** (EXIT from #PID<0.92.0>) an exception was raised:
    ** (UndefinedFunctionError) function :inets.stop/2 is undefined (module :inets is not available)
        :inets.stop(:httpc, :mix)
        (mix) lib/mix/utils.ex:578: Mix.Utils.read_httpc/1
        (mix) lib/mix/utils.ex:526: anonymous fn/2 in Mix.Utils.read_path/2
        (elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
        (elixir) lib/task/supervised.ex:35: Task.Supervised.reply/5
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Performing mix local.hex or mix local.hex --force resulted in the same message that :inets was not available.

This is a sign that while Elixir is installed, Erlang is not.

This can happen if one installs elixir via a package manager, rather than doing all the install steps.

In the case of Ubuntu 19.x, sudo apt install esl-erlang did not match a package; rather use sudo apt install erlang, which does differ from the install steps, unless you've included the Erlang Solutions repo.

Afterward, mix local.hex will work, as also mix deps.get.