Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elixir mix file - :applications vs :extra_applications - when to use which?

Tags:

elixir

From Elixir documentation:

:applications - all applications your application depends on at runtime. By default, this list is automatically inferred from your dependencies. Any extra Erlang/Elixir dependency must be specified in :extra_applications. Mix and other tools use the application list in order to start your dependencies before starting the application itself.

:extra_applications - a list of Erlang/Elixir applications that you want started before your application. For example, Elixir’s :logger or Erlang’s :crypto.

If the list for :applications is automatically inferred, then what are some example scenarios when we should add an application to :applications instead of :extra_applications? and vice versa?

like image 516
Ahmad Ferdous Avatar asked Jun 23 '17 18:06

Ahmad Ferdous


People also ask

What is mix EXS?

Our mix. exs defines two public functions: project , which returns project configuration like the project name and version, and application , which is used to generate an application file. There is also a private function named deps , which is invoked from the project function, that defines our project dependencies.

How do I start an Elixir application?

Starting applications Differently from other languages, Elixir does not have a main procedure that is responsible for starting your system. Instead, you start one or more applications, each with their own initialization and termination logic. When an application is started, the Application.

How do you compile Elixir?

You can compile an elixir file using the elixirc command. This will create a . beam file in the current directory for each module defined in your file. If you start iex in this directory your modules from the file will be available. Here you can read more about this command in the official guides.

What is a mix project?

In the Mix Project (ITMP) is a local registered charity (no. 1161486) that provides youth and community services across Somerset. We are based in Wiveliscombe, Taunton Deane, and we endeavour to provide services that are accessible to all with a focus on youth work.


1 Answers

If you use applications then no inference is done and extra_applications are not considered. When applications are not provided, they are set to something like this:

applications_inferred_from_deps ++ extra_applications

You use one or the other, but never both.

like image 126
michalmuskala Avatar answered Oct 22 '22 15:10

michalmuskala