mix

mix deps

Lists all dependencies and their status.

Dependencies must be specified in the mix.exs file in one of the following formats:

{app, requirement}
{app, opts}
{app, requirement, opts}

Where:

  • app is an atom
  • requirement is a version requirement or a regular expression
  • opts is a keyword list of options

By default, dependencies are fetched using the Hex package manager:

{:plug, ">= 0.4.0"}

By specifying such dependencies, Mix will automatically install Hex (if it wasn’t previously installed) and download a package suitable to your project.

Mix also supports Git and path dependencies:

{:foobar, git: "https://github.com/elixir-lang/foobar.git", tag: "0.1"}
{:foobar, path: "path/to/foobar"}

And also in umbrella dependencies:

{:my_app, in_umbrella: true}

Path and in umbrella dependencies are automatically recompiled by the parent project whenever they change. While fetchable dependencies like the ones using :git are recompiled only when fetched/updated.

The dependencies’ versions are expected to follow Semantic Versioning and the requirements must be specified as defined in the Version module.

Options

Below we provide a more detailed look into the available options.

Dependency definition options

  • :app - when set to false, does not read the app file for this dependency. By default, the app file is read

  • :env - the environment (as an atom) to run the dependency on; defaults to :prod

  • :compile - a command (string) to compile the dependency; defaults to a mix, rebar or make command

  • :optional - marks the dependency as optional. In such cases, the current project will always include the optional dependency but any other project that depends on the current project won’t be forced to use the optional dependency. However, if the other project includes the optional dependency on its own, the requirements and options specified here will also be applied.

  • :only - the dependency is made available only in the given environments, useful when declaring dev- or test-only dependencies; by default the dependency will be available in all environments. The value of this option can either be a single environment (like :dev) or a list of environments (like [:dev, :test])

  • :override - if set to true the dependency will override any other definitions of itself by other dependencies

  • :manager - Mix can also compile Rebar, Rebar3 and makefile projects and can fetch sub dependencies of Rebar and Rebar3 projects. Mix will try to infer the type of project but it can be overridden with this option by setting it to :mix, :rebar, :rebar3 or :make

  • :runtime - whether the dependency is part of runtime applications. Defaults to true which automatically adds the application to the list of apps that are started automatically and included in releases

Git options (:git)

  • :git - the Git repository URI
  • :github - a shortcut for specifying Git repos from GitHub, uses git:
  • :ref - the reference to checkout (may be a branch, a commit SHA or a tag)
  • :branch - the Git branch to checkout
  • :tag - the Git tag to checkout
  • :submodules - when true, initialize submodules for the repo
  • :sparse - checkout a single directory inside the git repository and use it as your Mix dependency. Search “sparse git checkouts” for more information.

Path options (:path)

  • :path - the path for the dependency
  • :in_umbrella - when true, sets a path dependency pointing to “../#{app}”, sharing the same environment as the current application

Deps task

mix deps task lists all dependencies in the following format:

APP VERSION (SCM)
[locked at REF]
STATUS

It supports the following options:

  • --all - checks all dependencies, regardless of specified environment

Summary

Functions

run(args)

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

Functions

run(args)

run(OptionParser.argv) :: :ok

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

Callback implementation for Mix.Task.run/1.

© 2012–2017 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/mix/1.4.5/Mix.Tasks.Deps.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部