From ad54b0c4626ce4ffcf043aa3a8ecdf73aae776b1 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 4 Feb 2026 21:33:41 +0100 Subject: [PATCH] Release.seed_admin: ensure app started when run via bin/mv eval Application.ensure_all_started(:mv) so Ash/Telemetry work (ETS table exists). Fixes Unknown Error / telemetry_handler_table in production entrypoint. --- lib/mv/release.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/mv/release.ex b/lib/mv/release.ex index 8893dcc..54bc245 100644 --- a/lib/mv/release.ex +++ b/lib/mv/release.ex @@ -34,6 +34,9 @@ defmodule Mv.Release do @doc """ Ensures an admin user exists from ENV (ADMIN_EMAIL, ADMIN_PASSWORD or ADMIN_PASSWORD_FILE). + Starts the application if not already running (required when called via `bin/mv eval`; + Ash/Telemetry need the running app). Idempotent. + - If ADMIN_EMAIL is unset: no-op (idempotent). - If ADMIN_PASSWORD (and ADMIN_PASSWORD_FILE) are unset and the user does not exist: no user is created (no fallback password in production). @@ -42,7 +45,11 @@ defmodule Mv.Release do `bin/mv eval "Mv.Release.seed_admin()"` to change the admin password without redeploying. """ def seed_admin do - load_app() + # Ensure app (and Telemetry/Ash deps) are started when run via bin/mv eval + case Application.ensure_all_started(@app) do + {:ok, _} -> :ok + {:error, {app, reason}} -> raise "Failed to start #{inspect(app)}: #{inspect(reason)}" + end admin_email = get_env("ADMIN_EMAIL", nil) admin_password = get_env_or_file("ADMIN_PASSWORD", nil) -- 2.47.2