Some modules are becoming unavailable at runtime

I have a phoenix application that was running fine until a few days ago when some modules (mostly deps like Ecto, Poison and Timex) are raising some errors for being unavailable at runtime. I even entered the server via console and checked that the modules were there. This error doesn’t happen on all requests but its getting on my nerves because i can figure it out.

Here are some examples

Elixir.UndefinedFunctionError: function Poison.Encoder.encode/2 is undefined (module Poison.Encoder is not available)

Elixir.UndefinedFunctionError: function Ecto.Queryable.to_query/1 is undefined (module Ecto.Queryable is not available)

Some help would definitely be appreciated.

1 Like

Any stack traces?

It’s hard to say anything with the info you’ve given.

1 Like

Not entirely sure but I’d definitely consider nuking your _build directory and recompiling.


All of them look something like this. Im pretty sure these modules are actually available at runtime, since this only occurs in a few (apparently random) requests

I also install and compile the dependencies in all builds, so they are always fresh.

What version of OTP and Elixir are you using?

erlang 24.3.4
elixir 1.13.4

Are you using umbrella apps?

How are you running the app? Release or mix run or something else? :slight_smile:

running from a docker-compose with mix phx.server

actually yes

All the stack traces i looked at show some Ecto function being called. So I’ll try update it to see it gets fixed later this week.

You need to add each dependency to each app that uses it. Adding to the root’s mix.exs works in dev, but not in prod.

1 Like

So I accidentally left the phoenix config code_reloader: true in prod, when I turned it off, the problems disappeared