Although EEx is bundled with the Elixir distribution it is not part of the Elixir core.
$ ls -1 /usr/local/Cellar/elixir/0.12.2/lib/
eex
elixir # <- Elixir core stuff is here
ex_unit
iex
mix
When you run mix escriptize
it bundles your project beam files, plus any project dependencies and the Elixir core beam files (from under lib/elixir), but none of the other libraries bundled in the Elixir distribution. So if your project uses EEx the resulting escript will fail reporting an undefined function for anything from EEx.
To resolve this, edit your mix.exs
file to add escript_embed_extra_apps: ["eex"]
to the options in the list returned by the project
function. Like this:
# mix.exs
def project do
[ app: :your_app_name,
version: "0.0.1",
elixir: "~> 0.12.2",
escript_main_module: YourAppName.CLI,
escript_embed_extra_apps: ["eex"],
deps: deps ]
end
Then rerun mix escriptize
.
(The string “eex” is used to locate the eex.app
file from under /usr/local/Cellar/elixir/0.12.2/lib/eex/ebin/
)
Posted by Dan M to elixir tips (2014-02-03 17:58)