** (RuntimeError) could not lookup Ecto repo Repo because it was not started or it does not exist

I had an instance of this issue.

I was trying to use Repo.preload() inside of a plug call for my controller like

  plug Plugs.Setup, %{
    is_navigation?: false,
    items: Items.list_active_items() |> Repo.preload(:info),
  }

  def index(conn, params) do
     #do something, return conn
  end

My fix was to pass it in during the plug call.

def call(conn, settings) do
    map = %{
      items: Items.list_active_items() |> Repo.preload([:art_information, :inventory_info]),
    }

    Map.merge(map)
    |> Enum.reduce(conn, fn {key, value}, acc -> assign(acc, key, value) end )
  end

I believe I had this error because the link for the repo isn’t started before you get into an action.