What does `runtime: false` mean in the Mixfile dependencies?
Asked Answered
L

1

13

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?

Lurlinelusa answered 23/10, 2018 at 22:39 Comment(0)
M
18

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.

Muniments answered 23/10, 2018 at 22:51 Comment(1)
The historical side note was especially helpful, thanks!Lurlinelusa

© 2022 - 2024 — McMap. All rights reserved.