Build, run, debug and test Erlang
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
In the main menu, go to
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 dialog (Ctrl+Alt+S) , navigate to .
Enable the option called Compile project with rebar.
In the main menu, go to
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.
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.
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.
In the main menu, go to 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
to save the configuration.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 Ctrl+Alt+S .
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.
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.
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.
In the Test Runner tool window that opens, you can see the output and manage the results of running your tests: