A module not found on a server, whereas locally it works

Phoenix app, has worked well for months. I’ve always used edeliver and distillery for deploy withno problem.

Now I’ve added a new library from hex.pm, deployed and:

 ** (UndefinedFunctionError) function SomeModule.some_func/1 is undefined (module SomeModule is not available)

However, locally it works. I’ve tried removing the app folder on the server completely and redeploying – didn’t pan out.

Hi, you probably need to add the new library to the applications list on your mix.exs, recreate your build, and redeploy.

1 Like

it’s https://github.com/pragdave/earmark

do I need to it to the applications list? I think not.

When this has happened to me before it’s because the release doesn’t contain the new library. By adding it to the applications list on mix.exs you tell distillery to add it to your release.

yes, but some of dependencies don’t require that they’re added to the application list. why not?

I agree with you that it is not very intuitive, but I think this is the way that distillery knows which libraries it should add to your release. If you find a better way please let me know :slight_smile:

I think that if you run your build command with the verbose flag Distillery will print out a message that relates to this problem https://github.com/bitwalker/distillery/issues/285 :

$ MIX_ENV=prod mix release --env=prod --verbose
==> Loading configuration..
==> Assembling release..
==> Building release eggl_docker:0.0.1 using environment prod
==> One or more direct or transitive dependencies are missing from
:applications or :included_applications, they will not be included
in the release:

:absinthe
:absinthe_ecto
:absinthe_plug
:blankable
:bodyguard
:confex
:cors_plug
:cowboy
:ex_syslogger
:gettext
:httpoison
:mariaex
:phoenix
:phoenix_ecto
:phoenix_pubsub
:sentry
:sweet_xml

This can cause your application to fail at runtime. If you are sure
that this is not an issue, you may ignore this warning.
2 Likes

All applications needed in production need to be listed. However, if you are using Elixir v1.4, you can remove the :applications entry altogether and Elixir will take care of it for you automatically.

4 Likes

is it either that all applications have to be listed or it has to be an empty list?

  def application do
    [mod: {Myapp123, []},
     applications: []]
  end

@gilded_honour, this is a nice summary of the changes in this regard in Elixir 1.4.