s-stepien

s-stepien

Application module `start` function not called?

Hi

I have fairly complicated Phoenix app (but it doubt that this is Phoenix related issue?). In it I have the MyApp.Application module with start(_type, _args) function. I noticed today (after long time without working on it), that the start() function isn’t called at all. In the mix.exs file, the mod: is set correctly to that module - I haven’t changed anything there.

How one can try to debug this? What is happening before call to start() - maybe something there hangs?

I’ve tried rebuild from scratch, re-get deps, etc. And nothing, the function will not be called.
When I created new project, all seems OK in it.

I’m using Erlang/OTP 28.1 and Elixir 1.18.4

Update:
If I use MIX_ENV=prod, then I can see print at the beginning of the start() function. But I want to use the dev env :slight_smile:

Most Liked

jswanner

jswanner

I believe @garrison is trying to get at is if any of the children in your application are running, if so then your application is running, and your endpoint is an easy one to test if it’s running.

How are you running your application? mix phx.server from the terminal, or some other way? Is it possible something is swallowing that IO you are using to debug? Instead of IO.inspect("here") you can try raise "here"

s-stepien

s-stepien

@garrison none of the children are started. The function is not called/entered.

@jswanner even with raise “here” it will not stop it. I’m using iex -S mix phx.server with some env variables.

Note that with MIX_ENV=prod it works, every time. With MIX_ENV=dev it does not. Only this MIX_ENV is different in invocation.

jswanner

jswanner

diff _build/{dev,prod}/lib/<app_name>/ebin/<app_name>.app

Last Post!

s-stepien

s-stepien

Hmmm

In fail case:

iex(2)> Application.started_applications()
[
{:myapp, [], []},
{:hex, ~c"hex", ~c"2.2.2"},
{:inets, ~c"INETS  CXC 138 49", ~c"9.4.2"},
{:ssl, ~c"Erlang/OTP SSL application", ~c"11.4"},
{:public_key, ~c"Public key infrastructure", ~c"1.18.3"},
{:asn1, ~c"The Erlang ASN1 compiler version 5.4.2", ~c"5.4.2"},
{:crypto, ~c"CRYPTO", ~c"5.7"},
{:mix, ~c"mix", ~c"1.18.4"},
{:iex, ~c"iex", ~c"1.18.4"},
{:elixir, ~c"elixir", ~c"1.18.4"},
{:compiler, ~c"ERTS  CXC 138 10", ~c"9.0.2"},
{:stdlib, ~c"ERTS  CXC 138 10", ~c"7.1"},
{:kernel, ~c"ERTS  CXC 138 10", ~c"10.4"}
]

iex(4)> Application.ensure_started(:phoenix_live_reload)
{:error, {:not_started, :logger}}
iex(5)> Application.ensure_started(:logger)
:ok
iex(6)> Application.ensure_started(:phoenix_live_reload)
{:error, {:not_started, :phoenix}}
iex(7)> Application.ensure_started(:phoenix)
{:error, {:not_started, :eex}}
iex(8)> Application.ensure_started(:eex)
:ok
iex(9)> Application.ensure_started(:phoenix)
{:error, {:not_started, :plug}}
iex(10)> Application.ensure_started(:plug)
{:error, {:not_started, :mime}}
iex(11)> Application.ensure_started(:mime)
:ok
iex(12)> Application.ensure_started(:plug)
{:error, {:not_started, :plug_crypto}}
iex(13)> Application.ensure_started(:plug_crypto)
:ok
iex(14)> Application.ensure_started(:plug)
{:error, {:not_started, :telemetry}}
iex(15)> Application.ensure_started(:telemetry)
:ok
iex(16)> Application.ensure_started(:plug)
:ok
iex(17)> Application.ensure_started(:phoenix)
{:error, {:not_started, :phoenix_pubsub}}
iex(18)> Application.ensure_started(:phoenix_pubsub)
:ok
iex(19)> Application.ensure_started(:phoenix)
{:error, {:not_started, :phoenix_template}}
iex(20)> Application.ensure_started(:phoenix_templete)
{:error, {~c"no such file or directory", ~c"phoenix_templete.app"}}

Update: in the end I was able to start them all and made sure that the file is there. So I do not know if this is related (or if I’m doing it correctly anyway).

Where Next?

Popular in Questions Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New

We're in Beta

About us Mission Statement