Can't compile on Heroku - (ArgumentError) missing :adapter configuration in config

Hi, having trouble compiling app on Heroku, see error below. I’ve followed the directions at Heroku. My lib/book_list/repo.ex file is appended.

ERRORS:

remote: == Compilation error in file lib/book_list/repo.ex ==
remote: ** (ArgumentError) missing :adapter configuration in config :book_list, BookList.Repo
remote:     lib/ecto/repo/supervisor.ex:70: Ecto.Repo.Supervisor.compile_config/2
remote:     lib/book_list/repo.ex:2: (module)
remote:     (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
remote:  !     Push rejected, failed to compile Elixir app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !	Push rejected to arcane-cliffs-95237

lib/booklist/repo.ex:

defmodule BookList.Repo do
  use Ecto.Repo, otp_app: :book_list

  @doc """
  Dynamically loads the repository url from the
  DATABASE_URL environment variable.
  """
  def init(_, opts) do
    {:ok, Keyword.put(opts, :url, System.get_env("DATABASE_URL"))}
  end
end

Looks like you are missing the ecto adapter config. The readme has an example here: https://github.com/elixir-ecto/ecto/blob/master/README.md but you can also set it in your config

1 Like

Hi, what is confusing me is that I have the code below config/prod.exs:

config :book_list, BookListWeb.Endpoint,
  load_from_system_env: true,
  url: [scheme: "https", host: "mysterious-meadow-6277.herokuapp.com", port: 443],
  force_ssl: [rewrite_on: [:x_forwarded_proto]],  cache_static_manifest: "priv/static/cache_manifest.json",
  secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE")


config :book_list, Hello.Repo,
  adapter: Ecto.Adapters.Postgres,
  url: System.get_env("DATABASE_URL"),
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
  ssl: true

That configures an adapter for Hello.Repo, not BookList.Repo.

2 Likes

My goodness, very sloppy today – thanks!

1 Like

Well, the app deployed, but now I get runaway error messages:

2018-06-15T20:45:32.499415+00:00 app[web.1]: (elixir) lib/keyword.ex:371: Keyword.fetch!/2
2018-06-15T20:45:32.499416+00:00 app[web.1]: (postgrex) lib/postgrex/protocol.ex:98: Postgrex.Protocol.connect/1
2018-06-15T20:45:32.499417+00:00 app[web.1]: (db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2
2018-06-15T20:45:32.499418+00:00 app[web.1]: (connection) lib/connection.ex:622: Connection.enter_connect/5
2018-06-15T20:45:32.499419+00:00 app[web.1]: (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
2018-06-15T20:45:32.499421+00:00 app[web.1]: Last message: nil
2018-06-15T20:45:32.499792+00:00 app[web.1]: 20:45:32.499 [error] GenServer #PID<0.24004.39> terminating
2018-06-15T20:45:32.499795+00:00 app[web.1]: ** (RuntimeError) Connect raised a KeyError error. The exception details are hidden, as
2018-06-15T20:45:32.499796+00:00 app[web.1]: they may contain sensitive data such as database credentials.

These scroll past at a high rate.

– no idea what do do here.

The app works fine locally. — I’m checking a possible inconsistency in the config.

Can you check if DATABASE_URL is properly set during application boot?

1 Like

Have you provisioned a postgres database on Heroku?

Also if you run heroku config from the project directory you should see a list of environment variables that will include a DATABASE_URL if you have a provisioned database for this Heroku Aplication.

1 Like