Hello.
I’m having a strange problem.
I started an application with Ecto, but I keep getting this error:
== Compilation error on file lib/cards.ex ==
** (ArgumentError) missing :adapter configuration in config :cards, Cards.Repo
lib/ecto/repo/supervisor.ex:37: Ecto.Repo.Supervisor.parse_config/2
lib/cards.ex:16: (module)
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
In my config file, I have this:
use Mix.Config
config :cards, ecto_repos: [Cards.Repo]
config :cards, Cards.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "ffff00123123",
database: "cards_repository_dev",
hostname: "localhost",
pool_size: 10
In my mix.exs file, I have this:
defmodule Cards.Mixfile do
use Mix.Project
def project do
[app: :cards,
version: "0.0.1",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.2",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
aliases: aliases,
deps: deps]
end
def application do
[mod: {Cards, []},
applications: [:logger, :postgrex, :ecto]]
end
defp deps do
[{:postgrex, "~> 0.11"},
{:ecto, ">= 0.0.0"}]
end
defp aliases do
["ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"]]
end
end
And in my cards
module, I have this:
defmodule Cards do
use Application
def start(_one, _two) do
import Supervisor.Spec, warn: false
children = [
worker(Cards.Repo, [])
]
Supervisor.start_link(children, strategy: :one_for_one)
end
end
defmodule Cards.Repo do
use Ecto.Repo, otp_app: :cards
end
I can’t get it to work! Why is that?
Edit: the worst part is that this applications is in a umbrella app, and it works OK in one of the apps as an umbrella dependency, but it doesn’t work on another app. Why? I can’t see why.
The only difference I spotted is that in the apps that work, a mix.lock
is available. How, on Earth, can the same application compile as a umbrella dependency in one app and it won’t compile on another app? How?