IntelliJ IDEA 2022.2 Help

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

  1. From the main menu, select Build | Build Project Build Project Ctrl+F9.

  2. View the output in the Build tool window that appears.

Erlang build with IDE

Build with Rebar

  1. Make sure Rebar3 is installed and configured.

  2. In the Settings/Preferences dialog (Ctrl+Alt+S), navigate to Build, Execution, Deployment | Compiler | Erlang Compiler.

  3. Enable the option called Compile project with rebar.

    Compile project with Rebar
  4. From the main menu, select Build | Build Project Build Project Ctrl+F9.

  5. View the output in the Build tool window that appears.

Erlang build with Rebar

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

  1. Create or open an Erlang project.

  2. Double-click the corresponding file in the Project view to open your application in the editor.

  3. Press Shift+F10 to execute the application. Alternatively, click the Run icon in the gutter on the left of the editor, and select Run Run '<configuration name>' Ctrl+Shift+F10 to execute the function in context.

    Run Erlang app from context
  4. 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.

  1. Make sure Rebar3 is installed and configured.

  2. From the main menu, select Run | Edit Configurations.

  3. In the dialog that appears, click Add New Configuration or press Alt+Insert to add a new configuration.

  4. Select Erlang Rebar from the menu that appears. An unnamed stub configuration will be created.

  5. 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.

    Pass Rebar Commands to IDE
  6. Click OK to save the configuration.

  7. Click Run | Run Run '<configuration name>', or press Shift+F10.

  8. View the output in the Run tool window that appears.

    Run with Rebar output

Debug Erlang app

  1. Create or open an Erlang project.

  2. Double-click the corresponding file in the Project view to open your application in the editor. Set breakpoints as necessary.

  3. 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.

  4. Make sure the Add debug info option is enabled in Settings/Preferences Ctrl+Alt+S | Compiler | Erlang Compiler.

    Erlang Compiler add debug_info
  5. Press Shift+F9 to start the debugging session. Alternatively, click the Run icon in the gutter on the left of the editor, and select Start debugger Debug '<configuration name>' to debug the code in context.

    Run Erlang app from context
  6. View the output and interact with the program data in the Debug tool window that appears.

    Erlang Debugger

Test Erlang applications

IntelliJ IDEA provides a way to test Erlang applications using EUnit testing framework.

Run EUnit test

  1. Create or open an Erlang project.

  2. In the Project view, double-click the file that contains tests to open it in the editor.

  3. Right-click anywhere in the editor window and click Run 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.

  4. In the Test Runner tool window that opens, you can see the output and manage the results of running your tests:

    Erlang Debugger
Last modified: 17 March 2022