Unable to start app in umbrella

Hi everybody,
I’m trying to separate my Ecto Repo from my Phoenix app.
I already have an umbrella app, but the ecto is not starting, I have an error saying : Could not start application transport: {:not_running, :db}

I don’t have any other error, message, I added log messages in Ecto.Repo.start_link and they are displaying, I don’t know how to debug it because I can’t access the iex console since the app is not starting.
Do you have any clue on how to debug it?

The code is here https://github.com/l-vincent-l/transport-site/tree/separate_repo

1 Like

Which versions of Erlang and Elixir are you using?

My .tool-versions file:

elixir 1.9.1-otp-22
erlang 22.1

While compiling your project:

==> transport
Compiling 73 files (.ex)

== Compilation error in file lib/datagouvfr/client.ex ==
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1

    The following arguments were given to IO.chardata_to_string/1:

        # 1
        nil

    Attempted function clauses (showing 2 out of 2):

        def chardata_to_string(string) when is_binary(string)
        def chardata_to_string(list) when is_list(list)

    (elixir) lib/io.ex:557: IO.chardata_to_string/1
    (elixir) lib/path.ex:515: Path.join/2
    lib/datagouvfr/client.ex:12: (module)
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir) lib/kernel/parallel_compiler.ex:229: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

You can also try forcing recompilation and see if that issue occurs for you as well:

mix compile --force

Thank you for taking time to investigate the problem.

I’m using :

  • elixir 1.9
  • erlang 21.2.5

But I think you’re on the master branch (and it’s outdated on my fork), can you checkout separate_repo, because this is the branch that has a problem

I narrowed it down to something easier to investigate I think.
Now with that commit https://github.com/etalab/transport-site/commit/4d4e0fc96d356300b7504ad30402855ab63c5046 I can’t start my app anymore.

So if I had a new app with ecto it’s working until I had this lines to application.ex

children =[
Repo
]

So I’m pretty sure that ecto can’t start, but it crashes silently.
Is there any way for me to add more log to understand what’s happening?

I tried something new, if I start the application with
iex -S mix run --no-start
And then start my applications one by one with Application.start/2
At the end of the process I can start :db without error and then when I try to start my main app (:transport) I have this error:

iex(143)> Application.start(:db)       
:ok
iex(144)> Application.start(:transport)
{:error, {:not_running, :db}}

Can you try replacing this:

children =[
  Repo
]

…with this?

children = [
  supervisor(Repo, [])
]

(or even YourApp.Repo).

I found my error.

In the configuration the module in config, :name_app, Repo, types: didn’t exist in this app.

I tried to find a way to contribute to Ecto and add a log when that happens, but I think I have to look in postgrex.

1 Like