Elixir - Application

  1. https://hexdocs.pm/elixir/Application.html

load paths

  1. https://hexdocs.pm/mix/Mix.Tasks.Compile.Elixir.html
  2. https://hexdocs.pm/elixir/Code.html#require_file/2

Elixir compiles all source files found in elixirc_paths (project configuration option in mix.exs).

elixirc_paths option can be set on per environment basis - see Elixir - Testing.

sometimes it’s necessary to load specific file that is located somewhere else (say, when running exs script file that depends on another exs file) - use Code.require_file/2 in this case:


NOTE: when relative_to argument is not passed, all paths are considered to be relative to project root directory.

evaluate or compile

  1. https://github.com/elixir-lang/elixir/issues/5073

ex files are meant to be compiled

exs files are used for scripting

each module is compiled into its own bytecode (beam) file:


compile in memory

in these cases bytecode modules are not written to disk - only loaded in memory:

compile to beam file


  1. https://stackoverflow.com/a/30688873/3632318

NOTE: iex starts IEx without running your app (same as irb).

Elixir application

NOTE: run is a default Mix task - specify it explicitly if it’s necessary to pass any task options.

Phoenix application

  1. https://hexdocs.pm/phoenix/up_and_running.html

start/stop in IEx

iex> Application.start(:neko)
iex> Application.stop(:neko)
iex> Application.stop(:logger)
iex> Application.ensure_all_started(:neko)