Rebar commands

Fred Hebert edited this page Mar 31, 2015 · 32 revisions

Rebar provides support for the most commonly encountered development activities, including:

  • Dependency management
  • Compilation
  • Unit testing and code coverage analysis
  • Documentation generation

In addition, it allows for OTP embedded system generation, taking advantage of the template processing afforded by rebar and the reltool application.

The most commonly used commands

Command Description
compile Compile all the available source files in the project.
eunit Perform unit testing using the EUnit application
doc Generate documentation using the EDoc application
clean Remove any generated artefacts from compilation, unit testing, etc.

Less commonly used commands (in alphabetical order)

Command Description
check-deps Check and display to be fetched dependencies specified in rebar.config
create Create a prototypical project (described by the supplied template)
create-app Create a prototypical OTP application (described by the template)
create-lib Create a prototypical OTP library (described by the template)
create-node Create a set of files (described by the template) that can be used by the generate command below to build an OTP embedded system
ct Run common_test suites
delete-deps Delete downloaded source files of the dependencies specified in the rebar.config
escriptize Create stand-alone escript executable using .beam-files in the ebin directory
generate Use the reltool application to construct an embedded system. See Release Handling page for details
generate-upgrade Build an upgrade package
get-deps Retrieve source files of the dependencies specified in the rebar.config
list-deps List the details of the dependencies specified in the rebar.config
update-deps Update the retrieved source files of the dependencies specified in the rebar.config
xref Use the xref application to analyze dependencies

Supported Source Formats

Rebar is capable of compiling a number of different source files via the "compile" command.

Source Target Description
src/*.erl ebin/*.beam Erlang source files
src/*.app.src ebin/*.app Erlang application specification
c_src/*.c priv/<app>.so C code for a port driver or NIF shared library
mibs/*.mib priv/mibs/*.bin SNMP mib files
src/*.xrl src/*.erl Leex analyzer generator files
src/*.yrl src/*.erl Yecc parser generator files
asn1/*.asn1 src/*.erl ASN-1 files
templates/*.dtl ebin/*_dtl.beam ErlyDTL template files (requires ErlyDTL to be installed)
src/*.lfe ebin/*.beam LFE source files (requires LFE to be installed)
src/*.peg ebin/*.beam Neotoma PEG grammars (requires Neotoma to be installed)
src/*.proto ebin/*_pb.beam, include/*_pb.hrl Protocol Buffers specifications (requires protobuffs to be installed)
dia/*.dia src/*.erl, include/*.hrl Diameter .erl files, Diameter .hrl headers


Options for the various commands are specified in the rebar.config configuration file. They are listed, below.

Command Options Description
compile erl_first_files The list of Erlang source files that should be compiled ahead of any other (for example, behavior modules)
compile erl_opts The options supported by the compile module, as described here
compile mib_first_files The list of mib files that should be compiled ahead of any other (for example, RFC mibs which are referenced in a mib file's IMPORTS section)
compile src_dirs List of directories containing Erlang source files
compile erlydtl_opts See ErlyDTL for details on the supported options
clean clean_files List of the files to delete; this is in addition to the files deleted by the clean command for a specific module
doc edoc_opts The options supported by the edoc module, as described here
escriptize escript_name The output filename for the escript (may include directories)
escriptize escript_incl_apps A list of other applications to include in the escript archive
escriptize escript_shebang The shebang line to prepend to the escript file (defaults to "#!/usr/bin/env escript\n")
escriptize escript_comment A comment to add at the top of the escript file (defaults to "%%\n")
escriptize escript_emu_args Arguments to pass to the Erlang emulator when running the escript, as described here (defaults to "%%!\n")
eunit eunit_opts The options supported by the eunit module, as described here
eunit cover_enabled Enable coverage analysis of Erlang programs
eunit eunit_compile_opts Same options as erl_opts to be used for eunit specific compile settings in addition to erl_opts
eunit eunit_first_files The list of EUnit Erlang source files that should be compiled ahead of any other (for example, behavior modules)
get-deps, delete-deps deps_dir Specify alternative directory to store downloaded dependencies
get-deps, delete-deps deps List of dependencies
generate target_dir Target directory
generate overlay_vars Overlay variables file
xref xref_warnings Enable xref warnings
xref xref_checks The options supported by the xref module analyze/2 functions, as described here
xref xref_queries Custom xref queries (xref manual has details) specified as {xref_queries, [{query_string(), expected_query_result()},...]}

You can also see example use of rebar.config options in rebar.config.sample. In addition, running rebar help displays general help and rebar help eunit xref prints command specific help.