I am at a loss why my Phoenix application, using releases, won’t deploy. From time to time the logs show this error:
May 21 11:36:06 AM Module build failed (from ./node_modules/sass-loader/dist/cjs.js): May 21 11:36:06 AM Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (93)
This is minor although pretty weird since I get this error 1 out of 5 times, and Render wants me to use node-sass 4.14.1
But mostly I can’t connect with the database:
# ** (RuntimeError) connect raised KeyError exception: key :database not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
I have set :show_sensitive_data_on_connection_error to true, but no details appear during deployment.
From the shell I can connect with the database with the internal connection string. So the database is up and running fine.
Although I get the message “Release created at _build/prod/rel/******!”, no _build folder is created!
I am out of ideas after struggling for many hours. Help is appreciated,
It looks like your app’s production config (possibly located in config/prod.exs) is missing the name of the database. Are you setting the database: in your prod config? Are you able to share your config so I can take a look? Please feel free to edit out any sensitive data from it before sharing
After building, the releases file isn’t executed on Render. However, if I build with the build.sh file locally releases.exs -is- executed. (I have followed this recipe: Deploy a Phoenix App | Render · Cloud Hosting for Developers, and it worked prefectly for a previous application)
Thanks for providing the extra info. It’s great you were able to narrow it down to executing the releases.exs file. Since I’m not too familiar with Elixir, I’m not sure what its process is for deciding which files to execute, unfortunately.
It may be useful to compare your previous application that worked correctly with your broken one, to see if there’s any difference in the configuration or file structure that sticks out to you.
After a lot of frustration I have found the cause of my problem. Besides the weird node problem I kept on getting this:
May 22 09:08:10 PM 19:08:10.253 [error] GenServer #PID<0.251.0> terminating
May 22 09:08:10 PM ** (RuntimeError) connect raised KeyError exception: key :database not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
May 22 09:08:10 PM (elixir) lib/keyword.ex:393: Keyword.fetch!/2
May 22 09:08:10 PM (postgrex) lib/postgrex/protocol.ex:161: Postgrex.Protocol.connect_endpoints/6
May 22 09:08:10 PM (db_connection) lib/db_connection/connection.ex:82: DBConnection.Connection.connect/2
May 22 09:08:10 PM (connection) lib/connection.ex:622: Connection.enter_connect/5
May 22 09:08:10 PM (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
May 22 09:08:10 PM Last message: nil
key :database not found.
This has nothing to do with releases.exs, nor the build script. In lib/repo.ex you have to add an init function:
defmodule FakeChains.Repo do
use Ecto.Repo,
otp_app: :fake_chains,
adapter: Ecto.Adapters.Postgres
# THIS NEEDS TO BE ADDED
def init(_type, config) do
{:ok, Keyword.put(config, :url, System.get_env("DATABASE_URL"))}
end
end
Dear Render.com, I find it pretty annoying that this documentation: Deploy a Phoenix App | Render · Cloud Hosting for Developers doesn’t show what needs to be done if your app uses a database. I mean, come on, the majority of all your phoenix apps probably have a database. And yes, I am writing this pretty pissed off.
I’ll echo Casper’s frustration here. It looks like that step is included with the Distillery docs, but not in the standard Phoenix releases documentation. Can you just update the Mix Releases documentation to include setting up the database as well? I assume most Phoenix apps are not without a database.