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
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.

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48475 226
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29703 241
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31307 143
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New

We're in Beta

About us Mission Statement