Hello,
I have :code.priv_dir(:my_lib)
working in iex
but returning {:error, :bad_name}
in escript.
Any idea ?
Thanks!
Hello,
I have :code.priv_dir(:my_lib)
working in iex
but returning {:error, :bad_name}
in escript.
Any idea ?
Thanks!
The escript documentation (at https://hexdocs.pm/mix/master/Mix.Tasks.Escript.Build.html) mentions that the priv
directory is not supported. I’m not sure exactly what the limitation is I wish it just worked also.
I’ve worked around this by making sure I create a /priv
directory with required libraries relative to the installed executable. That’s working well for my escript to be able to use the compiled esqlite3_nif.so
library.
Thanks for the reply !
What do you mean ? I don’t get how I can use a library which uses :code.priv_dir(:lib_name)
.
Unfortunately you cannot. We solved this in projects like ExDoc and the Phoenix installer by embedding the files into the modules. Something like:
def contents, do: unquote(File.read!("priv/foo"))