Sharing my experience with Elixir and Erlang interop

I just wanted to recount some problems I came across with trying to use some Erlang libraries from Elixir. I’m relatively new to the eco system (although I’ve been a developer for 40 years), but thought it might be interesting if I shared some of the stumbling blocks I came across.

I’m building a front end for an oauth server that I’d written in Erlang making use of the p1_oauth2 library.

  • I couldn’t work out how to expose the cowboy APIs directly from Phoenix so I’ve been having to refactor some code so I can re-implement the HTTP side of it in Elixir/Phoenix
  • For some reason that I don’t really understand we’ve had to repeat some of the underlying libraries in the mix deps list.
  • Mix doesn’t seem to understand the rebar3 configuration. The configuration for p1_oauth2 is in the oauth server code, but we have to repeat it in the mix configuration.
  • Elixir is more strict about configuration than Erlang. This caused a problem because the Elixir side checks the application names for the configurations, and p1_oauth2 uses the application name :oauth2 for its configuration. This gets rejected by mix and the only workable fix was to make changes to the p1_oauth2 library to align its name, the app.src file name and the configuration application name.
  • Our initial design for our oauth server was to ship a library with an example application that showed how to use it that was also used for tests. When we used this from other Erlang projects it was fine. However, mix choked on it with an incomprehensible error (which I guessed might have been due to project structure as rebar3 also gives useless errors when it gets a project structure it doesn’t like).

Hopefully this is at least interesting to some of you :slight_smile:

Kirit

2 Likes

What configuration do you mean? The only configuration done in rebar.config is how to build the application.

Also confused about your mention of configuration being under oauth2. There must be an application named oauth2 for that to work in Erlang. Is there a library named that in your project? Something else must be wrong that configuring the application oauth2 doesn’t work when you are running from an Elixir project.

Would need to see the error messages to know what the last issue is about, but yes, both build tools require certain structures of the projects they work on or use as dependencies.