Example Scenarios
Scenario 1: Simple Project Initialization
Setup:
my_app/
├── rebar.config
└── src/
└── my_app.erl
rebar.config:
{erl_opts, [debug_info]}.
Execution: rebar3 compile
Flow:
- Read
rebar.config→[{erl_opts, [debug_info]}] - No
rebar.lock→ empty lock - Create state with opts
- Apply default profile
- No plugins to install
- Register built-in providers
- Dispatch to compile command
Result: State initialized with debug_info enabled
Scenario 2: Project with Test Profile
rebar.config:
{erl_opts, [debug_info]}.
{profiles, [
{test, [
{deps, [meck]},
{erl_opts, [nowarn_export_all]}
]}
]}.
Execution: rebar3 as test compile
Flow:
- Load base config
- Apply
defaultprofile - Apply
testprofile:- Add
meckto deps - Add
nowarn_export_alltoerl_opts
- Add
- Result:
{erl_opts, [nowarn_export_all, debug_info]}
Scenario 3: Global Plugin Installation
~/.config/rebar3/rebar.config:
{plugins, [rebar3_hex]}.
Execution: rebar3 compile (in any project)
Flow:
- Load project config
- Detect global config exists
- Load global config
- Install
rebar3_hexplugin globally - Register hex providers (publish, etc.)
- Proceed with project compilation
Result: Hex commands available in all projects
Scenario 4: Environment Variable Override
rebar.config:
{erl_opts, [debug_info]}.
{profiles, [
{prod, [{erl_opts, [no_debug_info]}]}
]}.
Execution: REBAR_PROFILE=prod rebar3 compile
Flow:
- Load base config
- Detect
REBAR_PROFILE=prod - Apply
prodprofile - Result:
{erl_opts, [no_debug_info]}
Scenario 5: Offline Mode
Execution: rebar3 compile --offline
Flow:
- Parse
--offlineflag - Set
REBAR_OFFLINE=1environment variable - Skip starting
sslandinets - Set
offlineflag in state - Later stages skip network operations
Impact: Dependencies must already be cached