Mix v1.5.1 mix run View Source

Runs the given file or expression in the context of the application.

You can use this task to execute a particular file or command:

mix run -e Hello.world
mix run my_script.exs

This task provides a subset of the functionality available in the elixir executable, including setting up the System.argv/0 arguments:

mix run my_script.exs arg1 arg2 arg3

You can also use this task to simply start an application and keep it running without halting:

mix run --no-halt

Before running any command, the task compiles and starts the current application. Those can be configured with the options below.

You may also pass options specific to the elixir executable as follows:

elixir --sname hello -S mix run --no-halt

Command line options

  • --config, -c - loads the given configuration file
  • --eval, -e - evaluate the given code
  • --require, -r - requires pattern before running the command
  • --parallel, -p - makes all requires parallel
  • --no-compile - does not compile even if files require compilation
  • --no-deps-check - does not check dependencies
  • --no-archives-check - does not check archives
  • --no-halt - does not halt the system after running the command
  • --no-mixexs - allows the command to run even if there is no mix.exs
  • --no-start - does not start applications after compilation
  • --no-elixir-version-check - does not check the Elixir version from mix.exs

Link to this section Summary

Functions

A task needs to implement run which receives a list of command line args

Link to this section Functions

A task needs to implement run which receives a list of command line args.

Callback implementation for Mix.Task.run/1.