Annoying warning message regarding DynamicSupervisor

Hello everyone,

I’m working my way through the book Programming Ecto, and everything is going really well except for this 15+ line warning messages I get every time I run mix. My OCD self cannot stand it anymore.

Here’s the warning:

warning: :simple_one_for_one strategy is deprecated, please use DynamicSupervisor instead
  (elixir 1.12.0) lib/supervisor.ex:604: Supervisor.init/2
  (elixir 1.12.0) lib/supervisor.ex:556: Supervisor.start_link/2
  (stdlib 3.15) supervisor.erl:414: :supervisor.do_start_child_i/3
  (stdlib 3.15) supervisor.erl:400: :supervisor.do_start_child/2
  (stdlib 3.15) supervisor.erl:384: anonymous fn/3 in :supervisor.start_children/2
  (stdlib 3.15) supervisor.erl:1234: :supervisor.children_map/4

warning: :simple_one_for_one strategy is deprecated, please use DynamicSupervisor instead
  (elixir 1.12.0) lib/supervisor.ex:604: Supervisor.init/2
  (elixir 1.12.0) lib/supervisor.ex:556: Supervisor.start_link/2
  (stdlib 3.15) supervisor.erl:414: :supervisor.do_start_child_i/3
  (stdlib 3.15) supervisor.erl:400: :supervisor.do_start_child/2
  (stdlib 3.15) supervisor.erl:384: anonymous fn/3 in :supervisor.start_children/2
  (stdlib 3.15) supervisor.erl:1234: :supervisor.children_map/4

warning: Supervisor.start_child/2 with a list of args is deprecated, please use DynamicSupervisor instead
  (elixir 1.12.0) lib/supervisor.ex:826: Supervisor.start_child/2
  (db_connection 2.0.5) lib/db_connection/watcher.ex:21: DBConnection.Watcher.handle_call/3
  (stdlib 3.15) gen_server.erl:721: :gen_server.try_handle_call/4
  (stdlib 3.15) gen_server.erl:750: :gen_server.handle_msg/6
  (stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

And here is the, what I believe to be, the code to be modified

defmodule MusicDB.Application do
  @moduledoc false

  use Application

  def start(_type, _args) do
    children = [
      MusicDB.Repo
    ]
    opts = [strategy: :one_for_one, name: Test.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

I’ve tried solving this, but all the explanations I’ve found go over my head at my current level of understanding. Can you help me out here?

You might find your answer here => migrating from supervisor simple one for one.

I don’t think your issue is that file either (the one you pasted here).

1 Like

The code sample is quite old and You might want to update some packages… maybe simply remove mix.lock before refetching deps.

The error is not in your code, but in a dependency which uses simple_one_for_one strategy.

I guess it’s coming from poolboy…

3 Likes

Thanks Koko, that was it!

For other newbies reading this, I deleted mix.lock and then run mix deps.get, and the warning disappeared.

1 Like