Skip to content

Mix sometimes doesn't start all the applications #7930

@TBK145

Description

@TBK145

Precheck

  • Do not use the issues tracker for help or support (try Elixir Forum, Stack Overflow, IRC, etc.)
  • For proposing a new feature, please start a discussion on the Elixir Core mailing list
  • For bugs, do a quick search and make sure the bug has not yet been reported
  • Finally, be nice and have fun!

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 21 [erts-10.0.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

IEx 1.7.0-rc.0 (1164784b8) (compiled with Erlang/OTP 21)

OTP 21.0.2, both built from source

  • Operating system:
$ uname -srvm
Linux 4.17.6-1-ARCH #1 SMP PREEMPT Wed Jul 11 19:14:29 UTC 2018 x86_64

Current behavior

We have an umbrella consisting of multiple apps with dependencies on each other.

When I do a clean compilation and try iex -S mix phx.server apps will fail to start because of applications not being started.

$ make run
iex  --sname thijs -S mix phx.server
Erlang/OTP 21 [erts-10.0.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

13:46:10.896 [info] pid=<0.42.0> module=application_controller function=info_exited/3 line=1935 Application summa_automate exited: SummaAutomate.Application.start(:normal, []) returned an error: shutdown: failed to start child: SummaAutomateWeb.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Handler
        ** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, SummaAutomateWeb.Endpoint.HTTP}
            ** (EXIT) exited in: :gen_server.call(:ranch_server, {:set_new_listener_opts, SummaAutomateWeb.Endpoint.HTTP, 16384, [env: [dispatch: [{:_, [], [{["phoenix", "live_reload", "socket", "longpoll"], [], Plug.Adapters.Cowboy.Handler, {Phoenix.Transports.LongPoll, {SummaAutomateWeb.Endpoint, Phoenix.LiveReloader.Socket, :longpoll}}}, {["phoenix", "live_reload", "socket", "websocket"], [], Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {SummaAutomateWeb.Endpoint, Phoenix.LiveReloader.Socket, :websocket}}}, {["socket", "websocket"], [], Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {SummaAutomateWeb.Endpoint, SummaAutomateWeb.UserSocket, :websocket}}}, {:_, [], Plug.Adapters.Cowboy.Handler, {SummaAutomateWeb.Endpoint, []}}]}]], onresponse: #Function<1.129103586/4 in Plug.Adapters.Cowboy.add_on_response/3>]})
                ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
** (Mix) Could not start application summa_automate: SummaAutomate.Application.start(:normal, []) returned an error: shutdown: failed to start child: SummaAutomateWeb.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Handler
        ** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, SummaAutomateWeb.Endpoint.HTTP}
            ** (EXIT) exited in: :gen_server.call(:ranch_server, {:set_new_listener_opts, SummaAutomateWeb.Endpoint.HTTP, 16384, [env: [dispatch: [{:_, [], [{["phoenix", "live_reload", "socket", "longpoll"], [], Plug.Adapters.Cowboy.Handler, {Phoenix.Transports.LongPoll, {SummaAutomateWeb.Endpoint, Phoenix.LiveReloader.Socket, :longpoll}}}, {["phoenix", "live_reload", "socket", "websocket"], [], Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {SummaAutomateWeb.Endpoint, Phoenix.LiveReloader.Socket, :websocket}}}, {["socket", "websocket"], [], Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {SummaAutomateWeb.Endpoint, SummaAutomateWeb.UserSocket, :websocket}}}, {:_, [], Plug.Adapters.Cowboy.Handler, {SummaAutomateWeb.Endpoint, []}}]}]], onresponse: #Function<1.129103586/4 in Plug.Adapters.Cowboy.add_on_response/3>]})
                ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

So I tried to start one of the apps separately and noticed that not everything was started.

$ cd apps/summa_api/
$ iex -S mix run
Erlang/OTP 21 [erts-10.0.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

13:46:21.611 [info] pid=<0.295.0> module=Summa.Api.Application function=start/2 line=24 Starting application Summa.Api.Application
Interactive Elixir (1.7.0-rc.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Application.started_applications
[
  {:summa_api, 'summa_api', '1.8.0-dev'},
  {:logger, 'logger', '1.7.0-rc.0'},
  {:gettext, 'Internationalization and localization through gettext', '0.15.0'},
  {:phoenix,
   'Productive. Reliable. Fast. A productive web framework that\ndoes not compromise speed and maintainability.\n',
   '1.3.3'},
  {:phoenix_pubsub, 'Distributed PubSub and Presence platform\n', '1.0.2'},
  {:eex, 'eex', '1.7.0-rc.0'},
  {:poison, 'An incredibly fast, pure Elixir JSON library', '3.1.0'},
  {:plug,
   'A specification and conveniences for composable modules between web applications',
   '1.6.1'},
  {:mime, 'A MIME type module for Elixir', '1.3.0'},
  {:hex, 'hex', '0.18.1'},
  {:inets, 'INETS  CXC 138 49', '7.0'},
  {:ssl, 'Erlang/OTP SSL application', '9.0'},
  {:public_key, 'Public key infrastructure', '1.6.1'},
  {:asn1, 'The Erlang ASN1 compiler version 5.0.6', '5.0.6'},
  {:crypto, 'CRYPTO', '4.3'},
  {:mix, 'mix', '1.7.0-rc.0'},
  {:iex, 'iex', '1.7.0-rc.0'},
  {:elixir, 'elixir', '1.7.0-rc.0'},
  {:compiler, 'ERTS  CXC 138 10', '7.2.2'},
  {:stdlib, 'ERTS  CXC 138 10', '3.5.1'},
  {:kernel, 'ERTS  CXC 138 10', '6.0'}
]

When I switch back to Elixir 1.6.6 I get this output for the same command

$ kiex use 1.6.6
Using 1.6.6
$ iex -S mix run
Erlang/OTP 21 [erts-10.0.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

[compilation output...]

13:47:14.423 [info] pid=<0.2448.0> Setup running ...

13:47:14.429 [info] pid=<0.2448.0> Directories verified. Res = :ok

13:47:14.429 [info] pid=<0.2448.0> Setup finished processing hooks (Mode=:normal)...

13:47:14.622 [info] pid=<0.2463.0> [msg: 'Starting reporters with []\n', options: []]
13:47:14.708 [info] pid=<0.2488.0> module=Summa.Api.Application function=start/2 line=24 Starting application Summa.Api.Application
Interactive Elixir (1.6.6) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Application.started_applications
[
  {:summa_api, 'summa_api', '1.8.0-dev'},
  {:phoenix_ecto, 'Integration between Phoenix & Ecto', '3.3.0'},
  {:ecto, 'A database wrapper and language integrated query for Elixir', 
   '2.2.10'},
  {:poolboy, 'A hunky Erlang worker pool factory', '1.5.1'},
  {:decimal, 'Arbitrary precision decimal arithmetic.', '1.5.0'},
  {:exometer_zabbix, 'A Zabbix reporter backend for exometer_core\n', '0.1.0'},
  {:exometer_influxdb, 'InfluxDB reporter for exometer', '0.5.8'},
  {:exometer_core, 'Code instrumentation and metrics collection package.',
   '1.5.2'},
  {:folsom, 'Erlang based metrics system', '0.8.7'},
  {:bear, 'A set of statistics functions for erlang', '0.8.7'},
  {:setup, 'Generic setup application for Erlang-based systems', '1.8.4'},
  {:hut,
   'helper library for making Erlang libraries logging framework agnostic',
   '1.2.0'},
  {:hackney, 'simple HTTP client', '1.10.1'},
  {:metrics, 'A generic interface to different metrics systems in Erlang.',
   '1.0.1'},
  {:ssl_verify_fun, [], '1.1.1'},
  {:certifi, 'An OTP library', '2.0.0'},
  {:mimerl, 'An OTP library', '1.0.2'},
  {:idna, 'A pure Erlang IDNA implementation', '5.1.0'},
  {:unicode_util_compat, 'unicode_util compatibility library for Erlang < 20',
   '0.3.1'},
  {:phoenix_live_reload, 'Provides live-reload functionality for Phoenix',
   '1.1.5'},
  {:file_system,
   'A file system change watcher wrapper based on [fs](https://github.com/synrc/fs)',
   '0.2.6'},
  {:phoenix_html,
   'Phoenix.HTML functions for working with HTML strings and templates',
   '2.11.2'},
  {:cowboy, 'Small, fast, modular HTTP server.', '1.1.2'},
  {:cowlib, 'Support library for manipulating Web protocols.', '1.0.2'},
  {:ranch, 'Socket acceptor pool for TCP protocols.', '1.3.2'},
  {:logger, 'logger', '1.6.6'},
  {:gettext, 'Internationalization and localization through gettext', '0.15.0'},
  {:phoenix,
   'Productive. Reliable. Fast. A productive web framework that\ndoes not compromise speed and maintainability.\n',
   '1.3.3'},
  {:phoenix_pubsub, 'Distributed PubSub and Presence platform\n', '1.0.2'},
  {:eex, 'eex', '1.6.6'},
  {:poison, 'An incredibly fast, pure Elixir JSON library', '3.1.0'},
  {:plug,
   'A specification and conveniences for composable modules between web applications',
   '1.6.1'},
  {:mime, 'A MIME type module for Elixir', '1.3.0'},
  {:hex, 'hex', '0.18.1'},
  {:inets, 'INETS  CXC 138 49', '7.0'},
  {:ssl, 'Erlang/OTP SSL application', '9.0'},
  {:public_key, 'Public key infrastructure', '1.6.1'},
  {:asn1, 'The Erlang ASN1 compiler version 5.0.6', '5.0.6'},
  {:crypto, 'CRYPTO', '4.3'},
  {:mix, 'mix', '1.6.6'},
  {:iex, 'iex', '1.6.6'},
  {:elixir, 'elixir', '1.6.6'},
  {:compiler, 'ERTS  CXC 138 10', '7.2.2'},
  {:stdlib, 'ERTS  CXC 138 10', '3.5.1'},
  {:kernel, 'ERTS  CXC 138 10', '6.0'}
]

This is the mix file

defmodule Summa.Api.Mixfile do
  use Mix.Project

  def project do
    [app: :summa_api,
     version: String.trim(File.read!("../../VERSION")),
     build_path: "../../_build",
     config_path: "../../config/config.exs",
     deps_path: "../../deps",
     lockfile: "../../mix.lock",
     elixir: "~> 1.4",
     elixirc_paths: elixirc_paths(Mix.env),
     compilers: [:phoenix, :gettext] ++ Mix.compilers,
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps()]
  end

  def application do
    [mod: {Summa.Api.Application, []},
     extra_applications: [:logger]]
  end

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

  defp deps do
    [
      {:phoenix, "~> 1.3"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.0"},
      {:phoenix_html, "~> 2.6"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:cowboy, "~> 1.0"},
      # Monitoring & Statistics
      {:exometer_influxdb, "~> 0.5"},
      {:exometer_zabbix, "~> 0.1"},
      # Auto discovery of erlang nodes
      {:peerage, "~> 1.0", runtime: conditional_peerage()}
    ]
  end

  defp conditional_peerage() do
    cond do
      System.get_env("TOTAL_NODES") != nil -> true
      Mix.env == :prod -> true
      true -> false
    end
  end
end

Now when I switch back to 1.7.0-rc.0, it will start all the applications.

I checked the .app files and noticed this difference

summa_api.app on 1.6.6

{application,summa_api,
             [{applications,[kernel,stdlib,elixir,logger,gettext,
                             phoenix_pubsub,cowboy,phoenix_html,phoenix,
                             phoenix_live_reload,exometer_influxdb,
                             exometer_zabbix,phoenix_ecto]},
              {description,"summa_api"},
              {modules,['Elixir.Summa.Api.Application',
                        'Elixir.Summa.Api.Auth.Error',
                        'Elixir.Summa.Api.Channel',
                        'Elixir.Summa.Api.Channel.Diff',
                        'Elixir.Summa.Api.Channel.Version',
                        'Elixir.Summa.Api.Presence','Elixir.Summa.Api.PubSub',
                        'Elixir.Summa.Api.Registry',
                        'Elixir.Summa.Api.Service',
                        'Elixir.Summa.Api.Service.File']},
              {registered,[]},
              {vsn,"1.8.0-dev"},
              {mod,{'Elixir.Summa.Api.Application',[]}},
              {extra_applications,[logger]}]}.

summa_api.app on 1.7.0-rc.0

{application,summa_api,
             [{applications,[kernel,stdlib,elixir,logger]},
              {description,"summa_api"},
              {modules,['Elixir.Summa.Api.Application',
                        'Elixir.Summa.Api.Auth.Error',
                        'Elixir.Summa.Api.Channel',
                        'Elixir.Summa.Api.Channel.Diff',
                        'Elixir.Summa.Api.Channel.Version',
                        'Elixir.Summa.Api.Presence','Elixir.Summa.Api.PubSub',
                        'Elixir.Summa.Api.Registry',
                        'Elixir.Summa.Api.Service',
                        'Elixir.Summa.Api.Service.File']},
              {registered,[]},
              {vsn,"1.8.0-dev"},
              {mod,{'Elixir.Summa.Api.Application',[]}}]}.

I couldn't find anything about this in the changelog, so I'm thinking this is a regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions