Could not find Ecto repos in any of the apps in elixir project

Hi, I have an elixir project that needs to use Ecto:

then I create config folder and config.exs file: (elixir 1.13.1)

import Config

config :mishka_developer_tools, MishkaDeveloperTools.Repo,
  database: System.get_env("DATABASE_NAME"),
  username: System.get_env("DATABASE_USER"),
  password: System.get_env("DATABASE_PASSWORD"),
  hostname: System.get_env("DATABASE_HOST"),
  pool_size: 10,
  show_sensitive_data_on_connection_error: true

then create repo file:

defmodule MishkaDeveloperTools.Repo do
  use Ecto.Repo,
    otp_app: :mishka_developer_tools,
    adapter: Ecto.Adapters.Postgres
end

and add it on my Application file:

defmodule MishkaDeveloperTools.Application do
  use Application

  @impl true
  def start(_type, _args) do
    children = [
      MishkaDeveloperTools.Repo
    ]
    opts = [strategy: :one_for_one, name: MishkaDeveloperTools.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

but I have this error and every thing seems true:

warning: could not find Ecto repos in any of the apps: [:mishka_developer_tools].

You can avoid this warning by passing the -r flag or by setting the
repositories managed by those applications in your config/config.exs:

    config :mishka_developer_tools, ecto_repos: [...]
1 Like

Have you tried following the instructions in the error? You probably want to set that configuration.

1 Like

Well, the error is telling you exactly what you’re missing:

config :mishka_developer_tools, ecto_repos: [MishkaDeveloperTools.Repo]
2 Likes

this is fun, because I configured many elixir projects, and I did the same as:

config :mishka_developer_tools, MishkaDeveloperTools.Repo,
  database: .....

you mean I should do like this?

config :mishka_developer_tools, ecto_repos: [MishkaDeveloperTools.Repo],
  database: System.get_env("DATABASE_NAME"),
  username: System.get_env("DATABASE_USER"),
  password: System.get_env("DATABASE_PASSWORD"),
  hostname: System.get_env("DATABASE_HOST"),
  pool_size: 10,
  show_sensitive_data_on_connection_error: true

if yes, I have another error:

** (KeyError) key :database not found in: [telemetry_prefix: [:mishka_developer_tools, :repo], otp_app: :mishka_developer_tools, timeout: 15000, pool_size: 10]

I think I’m very tired and need to sleep ;)))

Yes, but something is wrong, it is not same as I did before, or Ecto was changed.
Anyway, I have another error when I use ecto_repos: [] and I could not find this structure in ecto documents.

No, those are two separate config entries. Just follow the docs.

4 Likes

I did this before :face_with_head_bandage:, I am very sorry my problem comes from docker I was editing the code outside the docker :nauseated_face: :nauseated_face: