PragTob

PragTob

How to make an Elixir library available to erlang users?

Hello Elixir friends,

I want to make one of my Elixir available/usable for our Erlang friends and be a “good BEAM citizen”. I was also told, that there isn’t really a good benchmarking library for Erlang so it seemed like a great idea.

Problem: I can’t figure out how to install Elixir libraries in Erlang. Threads like Writing a library for use in both Elixir and Erlang as well as the prominent Erlang/rebar3 usage on hex.pm made me think this was possible (although I always sort of wondered where it gets all the Elixir from)…

I setup a little test respository. However, benchee can not be found and neither can any other popular elixir hex package I can think of:

tobi@speedy ~/github/benchee_erlang $ rebar3 update
===> Updating package registry...
===> Writing registry to /home/tobi/.cache/rebar3/hex/default/registry
===> Generating package index...
===> Writing index to /home/tobi/.cache/rebar3/hex/default/packages.idx
tobi@speedy ~/github/benchee_erlang $ rebar3 compile
===> Package <<"benchee">> not found. Fetching registry updates and trying again...
===> Updating package registry...
===> Writing registry to /home/tobi/.cache/rebar3/hex/default/registry
===> Generating package index...
===> Writing index to /home/tobi/.cache/rebar3/hex/default/packages.idx
===> Package not found in registry: <<"benchee">>.
tobi@speedy ~/github/benchee_erlang $ rebar3 pkgs | grep poison
tobi@speedy ~/github/benchee_erlang $ rebar3 pkgs | grep phoenix

(btw. yes I have the rebar3_hex plugin installed but I think it does something else)

Adding benchee as a git dependency I get this error:

tobi@speedy ~/github/benchee_erlang $ rebar3 compile
===> Verifying dependencies...
===> Fetching benchee ({git,"git://github.com/PragTob/benchee.git"})
===> WARNING: It is recommended to use {branch, Name}, {tag, Tag} or {ref, Ref}, otherwise updating the dep may not work as expected.
===> Dependency failure: Application benchee not found at the top level of directory /home/tobi/github/benchee_erlang/_build/default/lib/benchee

It’s from this rebar3 issue - basically I don’t follow the standard rebar3/erlang project structure and yeah I’m an elixir project, so sure it doesn’t work.

So what do I do? Elixir and Erlang/rebar3 both use hex.pm and elixir people can use Erlang stuff but not the other way around? Do I just not know how?

How can I allow an Erlang project to use an Elixir library? Do they have to copy the files and compile them themselves to beam files? Do I setup a separate rebar3 package?

Sorry my erlang knowledge is also rather… improvable :slight_smile:

I feel like (and hope) I’m really missing something so please feel free to point it out. Thank you in advance :tada:

Most Liked

toraritte

toraritte

Apologies for the necrobump, but came across the Adopting Erlang online book, and there is a specific section in there about this topic (Development > Dependencies > Using Elixir Dependencies) that walks the reader through how to set up rebar_mix in Rebar3 projects to pull in Elixir hex.pm packages into Erlang applications.

tristan

tristan

Rebar3 Core Team

rebar_mix https://github.com/tsloughter/rebar_mix is the newer solution that handles transitive deps.

josevalim

josevalim

Creator of Elixir

Thanks @PragTob! I want to clarify that people should not expect the Elixir team to solve this. We already do all of the work to ensure you can use rebar/rebar3/make from Mix, the other direction is not quite up to us but rather to people using those other build tools. We will be glad to answer any questions or improve Elixir if necessary but it is up to the community to tackle the problem together.

josevalim

josevalim

Creator of Elixir

I believe you need something like rebar3_mix or rebar3_elixir for it to work. Try pinging t_slought/tristan or alisdair on #elixir-lang IRC channel.

PragTob

PragTob

Should they avoid it for that reason, then their loss :slight_smile: It’s also not used at run time, so there is no impact on the runtime release that gets distributed :slight_smile:

The library has a non trivial code base by now so I’m not gonna rewrite, just trying to be a good BEAM citizen.

Where Next?

Popular in Questions Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement