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.
Option | Type | Description |
---|---|---|
--all/-a | none | Clean all apps, including the dependencies |
--profile/-p | string | Specify a profile (alternative to |
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. |
--case | Comma separated list of strings | List of test cases to run. See the Common Test Documentation. |
--spec | Comma separated list of strings | List of Test Specifications |
--join_spec | Comma separated list of strings | Like |
--repeat | Integer | How often to repeat the tests |
--duration | String (format: HHMMSS) | Max allowed duration of the test run |
--until | String (format: HHMMSS) | Time until which to run the tests |
--force_stop |
| Force termination on test timeout |
--multiply_timetrap | Integer | Extends the timeout values for tests by a given multiplier value |
--scale_timetrap | Boolean | Enables automatic timeout value scaling, when using code coverage or tracing |
--abort_if_suite_is_missing | Boolean | Abort the test run if a test suite is missing (Default: true) |
--sys_config | String | List of OTP application config files (like |
--config | Comma separated list of strings | Config files to use when running tests. See the Common Test Documentation. |
--allow_user_terms | Boolean | Allow user defined config values in config files. See the Common Test Documentation. |
--decrypt_key | String | If the configuration file is encrypted, set the key to decrypt it |
--decrypt_file | String | If the configuration file is encrypted, point to the file containing the key to decrypt it |
--logdir | String | The directory in which test logs will be written. See the Common Test Documentation. Default: |
--logopts | Comma separated list of strings | Set common test logging options. See the Common Test Documentation. Default: |
--readable | Boolean | Adds test names with results on a per-test basis, and only displays common-test logs in the terminal on failing tests. Default: true |
-v, --verbose | Boolean | Enable verbose output. Default: false |
--verbosity | Integer | Set the level of Common Test verbosity |
-c, --cover | Boolean | Generate cover data |
--cover_export_name | String | Change the name of the code coverage file |
--label | String | Set a test label |
--basic_html | Boolean | show basic HTML |
--stylesheet | String | CSS stylesheet to apply to HTML output |
--create_priv_dir |
| change the behaviour of the private (scratch) directories creation done by Common Test |
--include | String | Additional directories containing include files. Option added for parity with ct_run, usually rebar3 should take care of include file paths |
--name | String | Start a distributed node with a given name |
--setcookie | String | Set a value for the distributed cookie |
--compile_only | Boolean | Compile 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.
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 $(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:
Option | Description |
---|---|
| a list of dialyzer warnings |
| display warnings when altering a PLT file (boolean) |
| the strategy for determining the applications which are included in the PLT file, |
| a list of applications to include in the PLT file (the applications in |
| the location of the PLT file, |
| the prefix to the PLT file, defaults to "rebar3" |
| a list of applications to include in the base PLT file |
| the location of base PLT file, |
| 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 ( |
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 The string must begin with The Default value is |
escript_shebang | string | Location of escript file to run. Defaults to |
escript_comment | string | Arbitrary comment to put into the generated escript. Must include a newline marker at the end. Defaults to |
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 |
--suite | Comma separated list of strings | List of test suites to run. Equivalent to EUnit's |
--file/-f | Comma separated list of strings | List of files to run (such as |
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.
Option | Type | Description |
---|---|---|
$task | string | Task to print help for. |
$namespace $task | string | Task within |
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 |
--bin | none | Return the |
--ebin | none | Return all |
--lib | none | Return the |
--priv | none | Return the |
--separator/-s | string | In case of multiple return paths, the separator character to use to join them. |
--src | none | Return the |
--rel | none | Return the |
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.
Option | Type | Description |
---|---|---|
--config | string | Allows to load a config file, if any. Defaults to the |
--name / --sname | atom | Starts the node in network mode. Equivalent to |
--setcookie | string | Sets the cookie for a distributed node. Equivalent to |
--script | 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. |
--start-clean | When specified, no apps are booted by the shell; useful to override release or shell tuple configurations in rebar.config | |
--relname / -r | atom | If multiple releases are present, specify which one to pick |
--relvsn / -v | string | If 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.
Option | Type | Description |
---|---|---|
$dependency | string | Dependencies to upgrade (comma-separated). |
version
Prints version for rebar3 and current Erlang.
xref
Runs cross reference analysis.
Updated over 2 years ago