10
votes

From the mix deps documentation:

:runtime - whether the dependency is part of runtime applications. If the :applications key is not provided in def application in your mix.exs file, Mix will automatically included all dependencies as a runtime application, except if runtime: false is given. Defaults to true.

According to mix compile.app docs:

:applications - all applications your application depends on at runtime. By default, this list is automatically inferred from your dependencies. Mix and other tools use the application list in order to start your dependencies before starting the application itself.

Does this mean that adding runtime: false to a dependency would make it not started as part of the application's supervision tree, but its functions would be available at compile-time?

1

1 Answers

10
votes

Like you mentioned, that's exactly the case. Marking a dependency runtime: false will not start it as part of the application supervision tree when your main application is started.

Before Elixir 1.4 we had to individually specify the applications that needed to be started by putting them in applications:

def application do
  [applications: [:logger, :bamboo]]
end

Now we use extra_applications instead and mark the specific dependencies runtime: false to remove them from the applications list at runtime.