I’m using erlpuzzle as a NIF so I can use it in Elixir. It has been working well, but a couple of days ago I refactored my code to extract some methods to another module, and although running on my local machine works, when I deploy it, it gives a weird error.
Slogan: init terminating in do_boot ({load_failed,[Elixir.MyAppCommon.Utils,Elixir.MyAppCommon]})
To give some context, before move erlpuzzle
to this new module (in a git repository), it worked well, and not sure why it complains about MyAppCommon.Utils
, since it wasn’t changed and worked well before.
This is my code to use the NIF.
defmodule :puzzle do
@on_load :load_nifs
def load_nifs do
file_name =
case :os.type() do
{:unix, :darwin} -> "puzzle_osx"
{:unix, :linux} -> "puzzle_deb"
_ -> raise "Unsupported operative system!"
end
path = "#{:code.priv_dir(:myapp)}/#{file_name}"
:erlang.load_nif(String.to_charlist(path), 0)
end
def cvec_from_file(_) do
raise "NIF cvec_from_file/1 not implemented"
end
...
end
I’m under the impression it is because I’m using defmodule :puzzle do
instead of something like defmodule MyApp.Puzzle do
, but if I try to use that, it gives a warning.
{:error, {:bad_lib, 'Library module name \'puzzle\' does not match calling module \'\'Elixir.MyApp.Puzzle\'\''}}
I’ve found this issue on StackOverflow, but I’m not sure where I need to rename the erlpuzzle
to match my module name, or if there is a simpler solution.