Swoosh related compile errors after switching branches

I have one feature branch in which I am implementing email handling using Swoosh. It is the only branch in which I have swoosh in my dependencies, etc. It all seems to run fine.

When I switch from that feature branch to any other branch, and run mix compile, I get this:

08:14:59.391 [warn]  The on_load function for module Elixir.Bw.Mailer returned:
{:undef,
 [
   {Swoosh.Mailer, :parse_config, [:bw, Bw.Mailer, [otp_app: :bw], []], []},
   {Bw.Mailer, :validate_dependency, 0, [file: 'lib/bw/mailer.ex', line: 6]},
   {:code_server, :"-handle_on_load/5-fun-0-", 1,
    [file: 'code_server.erl', ...]}
 ]}


08:14:59.390 [error] Process #PID<0.251.0> raised an exception
** (UndefinedFunctionError) function Swoosh.Mailer.parse_config/4 is undefined (module Swoosh.Mailer is not available)
    Swoosh.Mailer.parse_config(:bw, Bw.Mailer, [otp_app: :bw], [])
    lib/bw/mailer.ex:6: Bw.Mailer.validate_dependency/0
    (kernel 7.2) code_server.erl:1355: anonymous fn/1 in :code_server.handle_on_load/5

The application still seems to run fine though, but the message is a bit annoying. What is the root cause for this, and can it be solved/avoided?

1 Like