Adam Millerchip
Adam Millerchip

Reputation: 23091

Elixir app runs in iex, but need to add :eex as a dependency to run as a release

I've created a simple Cowboy/Plug application that uses Plug.Debugger.

These are my runtime dependencies in mix.exs

extra_applications: [:cowboy, :plug, :logger]

I am using Distillery via mix release to produce a release.

Both iex -S mix and running the release start the application fine, but they differ when an error occurs. For the iex session, Debugger correctly handles errors, but for the release, I get the following error:

** (UndefinedFunctionError) function EEx.Engine.fetch_assign!/2 is undefined (module EEx.Engine is not available)

I'm assuming EEx is used by Plug.Debugger to format the output.

I can fix this by adding :eex to extra_applications in mix.exs, rebuilding the release and re-running.

Why does :eex need to be listed as a dependency to run as part of a release, but not when run from iex?

Upvotes: 3

Views: 789

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121000

Elixir runtime adds some internal applications to OTP:

 @elixir_apps ~w(eex elixir ex_unit iex logger mix)a

One also can do Logger.log from the iex console etc. The OTP runtime, that is built by Distillery does not include these applications.

Upvotes: 3

Related Questions