mix deps.compile (Mix v1.19.0-dev)

View Source

Compiles dependencies.

By default, this task attempts to compile all dependencies. A list of dependencies can be given to compile multiple dependencies in order.

This task attempts to detect if the project contains one of the following files and act accordingly:

  • mix.exs - invokes mix compile
  • rebar.config - invokes rebar compile
  • Makefile.win- invokes nmake /F Makefile.win (only on Windows)
  • Makefile - invokes gmake on DragonFlyBSD, FreeBSD, NetBSD, and OpenBSD, invokes make on any other operating system (except on Windows)

The compilation can be customized by passing a compile option in the dependency:

{:some_dependency, "0.1.0", compile: "command to compile"}

If a list of dependencies is given, Mix will attempt to compile them as is. For example, if project a depends on b, calling mix deps.compile a will compile a even if b is out of date. This is to allow parts of the dependency tree to be recompiled without propagating those changes upstream. To ensure b is included in the compilation step, pass --include-children.

Compiling dependencies across multiple OS processes

If you set the environment variable MIX_OS_DEPS_COMPILE_PARTITION_COUNT to a number greater than 1, Mix will start multiple operating system processes to compile your dependencies concurrently.

While Mix and Rebar compile all files within a given project in parallel, enabling this environment variable can still yield useful gains in several cases, such as when compiling dependencies with native code, dependencies that must download assets, or dependencies where the compilation time is not evenly distributed (for example, one file takes much longer to compile than all others).

While most configuration in Mix is done via command line flags, this particular environment variable exists because the best number will vary per machine (and often per project too). The environment variable also makes it more accessible to enable concurrent compilation in CI and also during Mix.install/2 commands.

Command line options

  • --force - force compilation of deps
  • --skip-umbrella-children - skips umbrella applications from compiling
  • --skip-local-deps - skips non-remote dependencies, such as path deps, from compiling