Search code examples
erlangelixirjupyter-notebookzeromqelixir-mix

function is undefined in elixir (mix test)


I'm trying to install IElixir Jupyter notebook kernel on Xubuntu 16.04. I've successfully done it before on another machine with Xubuntu 16.04.

I have the latest erlang otp 19.3 and elixir 1.4.4 (installed using kiex).

After executing mix test i get an error about undefined :erlzmq_nif.context/1 function:

** (Mix) Could not start application ielixir: exited in: IElixir.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function :erlzmq_nif.context/1 is undefined (module :erlzmq_nif is not available)
            :erlzmq_nif.context(1)
            (ielixir) lib/ielixir.ex:13: IElixir.start/2
            (kernel) application_master.erl:273: :application_master.start_it_old/4

The thing is all the dependencies are succesfully installed and I am able to use :erlzmq_nif.context/1 in iex:

iex(1)> :erlzmq_nif.context 1
{:ok, ""}
iex(2)> 

I've copied my build of erlzmq to /usr/lib/erlang/lib so that I can use it in erlang too:

1> erlzmq_nif:context(3).
{ok,<<>>}
2> 

Why is this lib not visible to elixir when using mix?


Solution

  • I've not solved the problem, bu I've manage to get IElixir to work.

    What I've done was replace :erlzmq dependency in mix.exs with github: "zeromq/erlzmq" (notice no 2 in the repo name) which might not outperform erlzmq2 as it's not NIF based, but at least it works without problems.