Compilation Error on repo.ex

Hello, I am new to Phoenix Framework and I have been attempting to push an app that I have working locally to a remote Linux box from my local Mac. Some additional background, I have been following this tutorial for my deployment steps: https://www.digitalocean.com/community/tutorials/how-to-automate-elixir-phoenix-deployment-with-distillery-and-edeliver-on-ubuntu-16-04

Files are getting shipped over when I ‘mix edeliver build release’, but I get an error that says:

Compilation error in file lib/phxgas/repo.ex ==
** (ArgumentError) missing :adapter configuration in config :phxGas, PhxGas.Repo
lib/ecto/repo/supervisor.ex:70: Ecto.Repo.Supervisor.compile_config/2
lib/phxgas/repo.ex:2: (module)
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

Here’s what my repo.ex looks like:

defmodule PhxGas.Repo do
use Ecto.Repo, otp_app: :phxGas

@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

Does anybody have any troubleshooting suggestions for me? I have read a few posts from @OvermindDL1 that suggest I may need to add an adapter to my repo.ex. I’m just uncertain as to how to go about trying that if that’s indeed what I need to do.

Thanks for your time!

1 Like

Actually you need your adapter added to the configuration files. What are your configuration files contents (removing any potentially secure information of course)?

1 Like

Thanks so much for your willingness to help. Here are the contents of my configs.

.dev/config

APP=“phxGas”

BUILD_HOST=“domain”
BUILD_USER=“user”
BUILD_AT="/home/user/app_build"

PRODUCTION_HOSTS=“domain”
PRODUCTION_USER=“user”
DELIVER_TO="/home/user/app_release"

pre_erlang_get_and_update_deps() {
local _prod_secret_path="/home/user/config/prod.secret.exs"
if [ “$TARGET_MIX_ENV” = “prod” ]; then
__sync_remote "
ln -sfn ‘$_prod_secret_path’ ‘$BUILD_AT/config/prod.secret.exs’
"
fi
}

rel/config.exs

Path.join([“rel”, “plugins”, “*.exs”])
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

use Mix.Releases.Config,

default_release: :default,

default_environment: Mix.env()

environment :dev do

set dev_mode: true
set include_erts: false
set cookie: :“longstring1”
end

environment :prod do
set include_erts: true
set include_src: false
set cookie: :“longstring2”
set output_dir: “rel/phxgas”
end

release :phxGas do
set version: current_version(:phxGas)
set applications: [
:runtime_tools
]
end

config/prod.exs

use Mix.Config

config :phxGas, PhxGasWeb.Endpoint,
https: [port: 4000],
url: [host: “domain”, port: 443],
keyfile: System.get_env("/etc/ssl/private/domain.key"),
certfile: System.get_env("/etc/ssl/certs/domain.cer"),
cache_static_manifest: “priv/static/manifest.json”,
server: true,
code_reloader: false

config :logger, level: :info

mix.exs

defmodule PhxGas.Mixfile do
use Mix.Project

def project do
[
app: :phxGas,
version: “0.0.1”,
elixir: “~> 1.4”,
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
start_permanent: Mix.env == :prod,
aliases: aliases(),
deps: deps()
]
end

def application do
[
mod: {PhxGas.Application, []},
extra_applications: [:logger, :runtime_tools, :edeliver]
]
end

defp elixirc_paths(:test), do: [“lib”, “test/support”]
defp elixirc_paths(_), do: [“lib”]

defp deps do
[
{:phoenix, “~> 1.3.0”},
{:phoenix_pubsub, “~> 1.0”},
{:phoenix_ecto, “~> 3.2”},
{:postgrex, “>= 0.0.0”},
{:phoenix_html, “~> 2.10”},
{:phoenix_live_reload, “~> 1.0”, only: :dev},
{:gettext, “~> 0.11”},
{:cowboy, “~> 1.0”},
{:edeliver, “~> 1.4.6”},
{:distillery, “~> 1.5.2”}
]
end

defp aliases do
[
“ecto.setup”: [“ecto.create”, “ecto.migrate”, “run priv/repo/seeds.exs”],
“ecto.reset”: [“ecto.drop”, “ecto.setup”],
“test”: [“ecto.create --quiet”, “ecto.migrate”, “test”]
]
end
end

I added the following to prod.exs and config.exs

config :phxGas, PhxGas.Repo,
adapter: Ecto.Adapters.Postgres,
username: “username”,
password: “password”,
database: “dbname”,
pool_size: 15

I am no longer getting the adapter error, but I see

Failed to detect generated release at
user@domain:/home/user/app_build

Please set RELEASE_DIR in the config file to fix that,
or check that the APP variable is set correctly.

Should I set RELEASE_DIR to the same value as DELIVER_TO ("/home/user/app_release")

Thanks again for walking me through these!

Hooray! Adding the release_dir got me through that last error.

RELEASE BUILD OF PHXGAS WAS SUCCESSFUL!

Thanks a million!

Hah, sorry for the delay, I just got back! ^.^;

Awesome though! :smiley:

Oh, another question actually if you have a second.:grimacing: Do you happen to know where I change the release store location? I guess this more of an edeliver question, but now I’m getting

Copying phxGas.tar.gz to release store
scp: /home/user/phxGas/releases/*/phxGas.tar.gz: No such file or directory

I was thinking my release would be writing to /home/user/app_release

Yeah this bit is entirely an edeliver thing (I juse use distillery straight), I don’t use it so I’d recommend making a new thread about it. ^.^;

Ok, gotcha. Sounds like I should go that route as well. Thanks again for all your help!

1 Like