Build, run, debug and test Erlang
Last modified: 10 August 2022warning
The following is only valid when Erlang plugin is installed and enabled.
Compile and build Erlang projects
By default, IntelliJ IDEA uses the built-in Erlang compiler to build Erlang projects. The output of the compilation process is displayed in the Build tool window.
You can also delegate build actions to Rebar. In that scenario, the rebar3 compile
command is executed against your project.
Build with IntelliJ IDEA compiler
From the main menu, select Build |
Build Project Ctrl+F9.
View the output in the Build tool window that appears.

Build with Rebar
Make sure Rebar3 is installed and configured.
In the Settings/Preferences dialog (Ctrl+Alt+S), navigate to Build, Execution, Deployment | Compiler | Erlang Compiler.
Enable the option called Compile project with rebar.
note
If you need to modify the tool's configuration, click Configure rebar.
From the main menu, select Build |
Build Project Ctrl+F9.
View the output in the Build tool window that appears.

Run and debug Erlang applications
IntelliJ IDEA lets you run and debug your Erlang applications in the same way as you would any other application.
note
Run with IntelliJ IDEA
Create or open an Erlang project.
Double-click the corresponding file in the Project view to open your application in the editor.
Press Shift+F10 to execute the application. Alternatively, click the
icon in the gutter on the left of the editor, and select
Run '<configuration name>' Ctrl+Shift+F10 to execute the function in context.
note
A corresponding Run/Debug Configuration will be created ad-hoc and selected as the current default. You can run it anytime from anywhere in the project by pressing Shift+F10. The default can be changed via the corresponding menu on the Navigation bar.
View the output in the Run tool window that appears.
Run with Rebar
As an alternative to executing rebar3
commands from the terminal, IntelliJ IDEA provides a way to store each command, or a batch of commands, as a separate modifiable run/debug configuration.
Make sure Rebar3 is installed and configured.
From the main menu, select Run | Edit Configurations.
In the dialog that appears, click
or press Alt+Insert to add a new configuration.
Select Erlang Rebar from the menu that appears. An unnamed stub configuration will be created.
In the Command field, specify the
rebar3
commands that you want to run, separated by space, and fill out the rest of the information as needed.Click OK to save the configuration.
note
Configuration that was created or launched last is automatically selected as the current default. You can run it from anywhere in the project by pressing Shift+F10. The default can be changed via the corresponding menu on the Navigation bar.
Click Run |
Run '<configuration name>', or press Shift+F10.
View the output in the Run tool window that appears.
Debug Erlang app
Create or open an Erlang project.
Double-click the corresponding file in the Project view to open your application in the editor. Set breakpoints as necessary.
IntelliJ IDEA debugger requires the Erlang Port Mapper Daemon (EPMD) to be up and running. To get it running, start a random Erlang node on your machine, for instance with the
erl -sname foo -s init stop -noshell
CLI command.Make sure the Add debug info option is enabled in Settings/Preferences Ctrl+Alt+S | Compiler | Erlang Compiler.
Press Shift+F9 to start the debugging session. Alternatively, click the
icon in the gutter on the left of the editor, and select
Debug '<configuration name>' to debug the code in context.
note
The corresponding run/debug configuration will be created ad-hoc in this scenario.
View the output and interact with the program data in the Debug tool window that appears.
Test Erlang applications
IntelliJ IDEA provides a way to test Erlang applications using EUnit testing framework.
note
To debug failed tests, use the general debugging procedure.
Run EUnit test
Create or open an Erlang project.
In the Project view, double-click the file that contains tests to open it in the editor.
Right-click anywhere in the editor window and click
Run '<your_test_name>' (or press Ctrl+Shift+F10) to execute all tests in this file.
Depending on how the project was set up, a corresponding EUnit run configuration will be created for it ad-hoc:
Erlang Eunit for a bare-bones Erlang project.
Erlang Rebar Eunit for a project built with Rebar3.
note
To learn about managing run/debug configurations, refer to the dedicated help section.
In the Test Runner tool window that opens, you can see the output and manage the results of running your tests:
note
To learn more about running and debugging tests in IntelliJ IDEA, refer to the dedicated help section.
Thanks for your feedback!