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 dependencies 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.

OptionTypeDescription
--all/-anoneClean all apps, including the dependencies
--profile/-pstringSpecify 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:

OptionTypeDescription
--dirComma separated list of stringsCompile and run all test suites in the specified directories.
--suiteComma separated list of stringsCompile and run all test suites specified. Must be specified by full path, either absolute or relative to the current directory.
--groupComma separated list of stringsTest groups to run. See the Common Test Documentation.
--caseComma separated list of stringsList of test cases to run. See the Common Test Documentation.
--specComma separated list of stringsList of Test Specifications
--join_specComma separated list of stringsLike --spec but merges all the specifications into one and does a single run.
--repeatIntegerHow often to repeat the tests
--durationString (format: HHMMSS)Max allowed duration of the test run
--untilString (format: HHMMSS)Time until which to run the tests
--force_stoptrue | false | skip_restForce termination on test timeout
--multiply_timetrapIntegerExtends the timeout values for tests by a given multiplier value
--scale_timetrapBooleanEnables automatic timeout value scaling, when using code coverage or tracing
--abort_if_suite_is_missingBooleanAbort the test run if a test suite is missing (Default: true)
--sys_configStringList of OTP application config files (like sys.config) that should be applied by Rebar3 before the test run.
--configComma separated list of stringsConfig files to use when running tests. See the Common Test Documentation.
--allow_user_termsBooleanAllow user defined config values in config files. See the Common Test Documentation.
--decrypt_keyStringIf the configuration file is encrypted, set the key to decrypt it
--decrypt_fileStringIf the configuration file is encrypted, point to the file containing the key to decrypt it
--logdirStringThe directory in which test logs will be written. See the Common Test Documentation. Default: _build/test/logs
--logoptsComma separated list of stringsSet common test logging options. See the Common Test Documentation. Default: _build/test/logs
--readableBooleanAdds test names with results on a per-test basis, and only displays common-test logs in the terminal on failing tests. Default: true
-v, --verboseBooleanEnable verbose output. Default: false
--verbosityIntegerSet the level of Common Test verbosity
-c, --coverBooleanGenerate cover data
--cover_export_nameStringChange the name of the code coverage file
--labelStringSet a test label
--basic_htmlBooleanshow basic HTML
--stylesheetStringCSS stylesheet to apply to HTML output
--create_priv_dirauto_per_run | auto_per_tc | manual_per_tcchange the behaviour of the private (scratch) directories creation done by Common Test
--includeStringAdditional directories containing include files. Option added for parity with ct_run, usually rebar3 should take care of include file paths
--name
--sname
StringStart a distributed node with a given name
--setcookieStringSet a value for the distributed cookie
--compile_onlyBooleanCompile the project with the test configuration specified, but without running the tests

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.

OptionTypeDescription
--reset/-rnoneResets all cover data
--verbose/-vnonePrints 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.

OptionTypeDescriptionDefault
--update-plt/-ubooleanEnable updating the PLT. Default: truetrue
--succ-typings/-sbooleanEnable success typing analysis. Default: truetrue

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

PLT files are named $(prerix)_$(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:

OptionDescription
warningsa list of dialyzer warnings
get_warningsdisplay warnings when altering a PLT file (boolean)
plt_appsthe 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_appsa list of applications to include in the PLT file (the applications in base_plt_apps will already be in the list)
plt_locationthe location of the PLT file, local to store in the profile's base directory (default) or a custom directory.
plt_prefixthe prefix to the PLT file, defaults to "rebar3"
base_plt_appsa list of applications to include in the base PLT file
base_plt_locationthe location of base PLT file, global to store in $HOME/.cache/rebar3 (default) or a custom directory
base_plt_prefixthe 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 OptionTypeDescription
escript_main_appatomName 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_namestringName of the generated escript, and default module name to boot (Module:main(_)).
Defaults to the value for escript_main_app
escript_incl_appslist of atomsList of applications to include in the escript archive aside from the main app and its dependencies (from the app file). Defaults to []
escript_emu_argsstringEscript 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_shebangstringLocation of escript file to run. Defaults to "#!/usr/bin/env escript\n". The end of line marker must be included in the string.
escript_commentstringArbitrary 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.

OptionTypeDescription
--cover/-cBooleanGenerate cover data
--verbose/-vBooleanVerbose output
--appComma separated list of stringsList of applications to run tests for. Equivalent to EUnit's [{application, App}].
--suiteComma separated list of stringsList of test suites to run. Equivalent to EUnit's [{module, Suite}].
--file/-fComma separated list of stringsList of files to run (such as test/my_tests.beam), equivalent to Eunit's [{file, File}].

Runs in the test profile.

get-deps

🚧

Not Required

Unlike rebar2 this command is not required for fetching dependencies. The compile command will result in dependencies being fetched and then built if they aren't already. This command is useful if you have a specific use case that requires fetching dependencies separate from compilation.

Fetch project dependencies.

help

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

OptionTypeDescription
$taskstringTask to print help for.
$namespace $taskstringTask within $namespace to print help for

new

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

OptionTypeDescription
--force/-fnoneOverwrite existing files.
help $templatenoneDisplay all variables and arguments for each template

path

Print paths to build dirs in current profile.

--appComma separated list of stringsComma separated list of applications to return paths for.
--basenoneReturn the base path of the current profile.
--binnoneReturn the bin path of the current profile.
--ebinnoneReturn all ebin paths of the current profile's applications.
--libnoneReturn the lib path of the current profile.
--privnoneReturn the priv path of the current profile.
--separator/-sstringIn case of multiple return paths, the separator character to use to join them.
--srcnoneReturn the src path of the current profile's applications.
--relnoneReturn the rel path of the current profile.

pkgs

Find the details about a package, and its related versions: rebar3 pkgs $name

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:compile() or r3: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.

OptionTypeDescription
--configstringAllows to load a config file, if any.

Defaults to the sys_config entry defined for relx if present.
--name / --snameatomStarts the node in network mode. Equivalent to erl's -name and -sname options.
--setcookiestringSets the cookie for a distributed node. Equivalent to erl's -setcookie option
--scriptstringpath to an escript to be evaluated before applications are started
--appsstringComma-separated list of application names to be booted.

Defaults to the apps in the relx release if present.
--start-cleanWhen specified, no apps are booted by the shell; useful to override release or shell tuple configurations in rebar.config
--relname / -ratomIf multiple releases are present, specify which one to pick
--relvsn / -vstringIf multiple releases are present, specify which version to use

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.

OptionTypeDescription
$dependencystringDependencies 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.

Updated 3 months ago

Commands


Available tasks to run with rebar3

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.