2
votes

I have an Elixir project that uses mix. I already use some built-in erlang modules, but now I need to use a third party module I found on Github.

How do I import, build and call a third party Erlang module from Elixir?

EDIT: The module I am interested in right now is located at https://github.com/aggelgian/erlang-algorithms , specifically, the edmonds_karp module.

1
Does that module use rebar? Can you give us the URL of that repo?Dogbert

1 Answers

8
votes

Adding third-party erlang packages is quite easy in elixir. If the package isn't on Hex.pm, then you can just use the github url. E.g. in mix.exs:

defp deps do
  [
    {:erlang_algorithms, github: 'aggelgian/erlang-algorithms'},
  ]
end

Then you can just run mix deps.get

However in your case this will fail because the package doesn't have an app file. To fix this change the above to be:

  defp deps do
    [
      {:erlang_algorithms, github: 'aggelgian/erlang-algorithms', app: false},
    ]
  end

Then again run mix deps.get.

Now you can access the erlang modules available in the package:

E.g.

:dfs.run(arg1, arg2)