rebar3



Build better Erlang.

Commands

Available tasks to run with rebar3

Each command represents a task which runs one or more providers to fulfill the task.

as

Higher order task which takes a profile name and list of tasks to run under that profile.

compile

After ensuring all dependencies are available, and fetching them if they are not, compile will compile the needed depdendencies and the project's apps .app.src and .erl files.

clean

Removes compiled beam files from apps.

The clean command by default removes the beam files for top-level applications. It does so while respecting profiles, which means that 'rebar3 clean' will only clean the default profile, and 'rebar3 as test clean' will only clean the test profile.

The argument --all can be added to clear dependencies' beams as well as top-level apps.

Option
Type
Description

--all/-a

none

Clean all apps, including the dependencies

--profile/-p

string

Specify a profile (alternative to rebar3 as <profile> clean)

ct

Runs common tests for the project located under the test/ directory.

Most Common Test options as described in the Erlang documentation for ct_run are available. Some common ones are described below:

Option
Type
Description

--dir

Comma separated list of strings

Compile and run all test suites in the specified directories.

--suite

Comma separated list of strings

Compile and run all test suites specified. Must be specified by full path, either absolute or relative to the current directory.

--group

Comma separated list of strings

Test groups to run. See the Common Test Documentation.

--config

Comma separated list of strings

Config files to use when running tests. See the Common Test Documentation.

--logdir

String

The directory in which test logs will be written. See the Common Test Documentation. Default: _build/test/logs

-v, --verbose

Boolean

Enable verbose output. Default: false

-c, --cover

Boolean

Generate cover data

Runs in the test profile.

cover

Performs coverage analysis on modules called by Common Test or Eunit test suites. Call as rebar3 do ct, cover, rebar3 do eunit, cover or the combination of both with rebar3 do eunit, ct, cover while the {cover_enabled, true} option is in your rebar config file or if the cover flags were used with these commands individually.

An HTML report is generated.

Option
Type
Description

--reset/-r

none

Resets all cover data

--verbose/-v

none

Prints coverage analysis in the terminal.

Specific modules can be blacklisted from code coverage by adding {cover_excl_mods, [Modules]} to the config file. Specific applications can be blacklisted by adding {cover_excl_apps, [AppNames]} to the config file.

deps

Lists dependencies, whether they're source or package dependencies, and whether they're locked or not. Those that are locked but not matching the lock file are followed by an asterisk (*)

do

Higher order provider for running multiple tasks in a sequence, separated by commas. Example: rebar3 do a, b, c

dialyzer

Builds and keeps up-to-date a suitable PLT, and uses it to carry out success typing analysis on the current project.

Option
Type
Description
Default

--update-plt/-u

boolean

Enable updating the PLT. Default: true

true

--succ-typings/-s

boolean

Enable success typing analysis. Default: true

true

For instructions on suppressing warnings see the Requesting or Suppressing Warnings in Source Files section of the Dialyzer documentation.

PLT files are named <prefix>_<otp_release>_plt; The base PLT is a PLT containing the core applications often required for a project's PLT. One base PLT is created per OTP version and stored in base_plt_location. A base PLT is then used to build project PLTs.

The following (optional) configurations can be added to a proplist of options dialyzer in rebar.config:

Option
Description

warnings

a list of dialyzer warnings

get_warnings

display warnings when altering a PLT file (boolean)

plt_apps

the strategy for determining the applications which are included in the PLT file, top_level_deps to include just the direct dependencies or all_deps to include all nested dependencies (the direct dependent applications are listed in applications and included_applications of their .app files.)

plt_extra_apps

a list of applications to include in the PLT file (the applications in base_plt_apps will already be in the list)

plt_location

the location of the PLT file, local to store in the profile's base directory (default) or a custom directory.

plt_prefix

the prefix to the PLT file, defaults to "rebar3"

base_plt_apps

a list of applications to include in the base PLT file

base_plt_location

the location of base PLT file, global to store in $HOME/.cache/rebar3 (default) or a custom directory

base_plt_prefix

the prefix to the base PLT file, defaults to "rebar3"

edoc

Generates documentation using doc.
Runs in the docs profile.

escriptize

Generates an escript executable containing the project's and its dependencies' BEAM files.

Config Option
Type
Description

escript_main_app

atom

Name of the application to turn to an escript. Defaults to the top-level app if there is only one.

When using an umbrella repository (with multiple top-level apps), this value must be specified.

escript_name

string

Name of the generated escript, and default module name to boot (Module:main(_)).
Defaults to the value for escript_main_app

escript_incl_apps

list of atoms

List of applications to include in the escript archive aside from the main app and its dependencies (from the app file). Defaults to []

escript_emu_args

string

Escript emulator arguments (after %%! in escript declarations).

The string must begin with %%! and end with a line break. An example string would be "%%! +sbtu +A0\n".

The Default value is "%%! -escript main MainApp\n"

escript_shebang

string

Location of escript file to run. Defaults to "#!/usr/bin/env escript\n". The end of line marker must be included in the string.

escript_comment

string

Arbitrary comment to put into the generated escript. Must include a newline marker at the end.

Defaults to %%\n.

To override the default module name for the escript (which is expected to be the same as the escript_name), add -escript main Module to escript_emu_args

Example escript configuration from relx:

{escript_emu_args, "%%! +sbtu +A0 -noinput\n"}.
{escript_incl_apps, [getopt, erlware_commons, bbmustache, providers, relx]}.

eunit

Runs eunit tests on project apps.

Option
Type
Description

--cover/-c

Boolean

Generate cover data

--verbose/-v

Boolean

Verbose output

--app

Comma separated list of strings

List of applications to run tests for. Equivalent to EUnit's [{application, App}].

--suite

Comma separated list of strings

List of test suites to run. Equivalent to EUnit's [{module, Suite}].

--file/-f

Comma separated list of strings

List of files to run (such as test/my_tests.beam), equivalent to Eunit's [{file, File}].

Runs in the test profile.

get-deps

Fetch project dependencies.

help

Displays a list of tasks or help for a given task or subtask.

Option
Type
Description

<task>

string

Task to print help for.

<namespace> <task>

string

Task within <namespace> to print help for

new

Creates a new project from templates. See a list of available templates by providing no arguments.

Option
Type
Description

--force/-f

none

Overwrite existing files.

help <template>

none

Display all variables and arguments for each template

path

Print paths to build dirs in current profile.

--app

Comma separated list of strings

Comma separated list of applications to return paths for.

--base

none

Return the base path of the current profile.

--bin

none

Return the bin path of the current profile.

--ebin

none

Return all ebin paths of the current profile's applications.

--lib

none

Return the lib path of the current profile.

--priv

none

Return the priv path of the current profile.

--separator/-s

string

In case of multiple return paths, the separator character to use to join them.

--src

none

Return the src path of the current profile's applications.

--rel

none

Return the rel path of the current profile.

pkgs

Lists available packages.

release

Builds release of project. Call rebar3 help release for arguments.

relup

Creates a relup from 2 releases. Call rebar3 help relup for arguments.

report

Generates contextual data to include in bug reports

Example usage: rebar3 report "mytask --arg1 --arg2"

shell

Runs a shell with project apps and deps in path.

The shell booted with this command has an agent running allowing to run rebar3 commands dynamically, such as r3:do(compile) or r3:do(upgrade), and have new modules automatically reloaded. Specific namespaces can be reached by calling r3:do(Namespace, Command). No arguments can be passed to these commands.

Option
Type
Description

--config

string

Allows to load a config file, if any.

Defaults to the sys_config entry defined for relx if present.

--name / --sname

atom

Starts the node in network mode. Equivalent to erl's -name and -sname options.

--setcookie

string

Sets the cookie for a distributed node. Equivalent to erl's -setcookie option

--script_file

string

path to an escript to be evaluated before applications are started

--apps

string

comma-separated list of application names to be booted.

Defaults to the apps in the relx release if present.

tar

Builds a compressed tar archive of release built of project. Call rebar3 help tar for arguments.

tree

Prints a tree of dependencies and transitive dependencies of the project.

lock

Get unbuilt dependencies to be added to the rebar.lock file. They will just have been downloaded, but none of their build script should have run. Though this is not necessarily true with pre/post hooks and dep plugins.

unlock

Unlocks dependencies. If no dependency is mentioned, the command unlocks all of them. If any specific top-level dependencies (separated by commas) are listed as argument, those are unlocked.

A new lock file is then generated, or the existing lock file is removed in case no locks remain.

This command should be used when one or more dependencies have been taken out of rebar.config, but remain in the lock file.

update

Updates the package index.

upgrade

Upgrades dependencies and updates the lock file accordingly.

Option
Type
Description

<dependency>

string

Dependencies to upgrade (comma-separated).
If no dependency is mentioned, all dependencies are upgraded.

version

Prints version for rebar3 and current Erlang.

xref

Runs cross reference analysis.

Commands

Available tasks to run with rebar3