Elixir and breakpoints in Visual Studio Code

I have, for a long time now, thought it wasn't possible to use breakpoints in Elixir with Visual Studio Code. Turns out I was wrong.

After doing a Google search for something related, I came across this article:

Elixir Development with Visual Studio Code

It explains how to use Visual Studio Code's debug feature in combination with Elixir. This allows you to use breakpoints and it seems to work quite well.

Basically, all you need to do is to add a configuration in a file called launch.json inside the .vscode/ folder. Add something like this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "mix_task",
      "name": "mix phx.server",
      "request": "launch",
      "task": "phx.server",
      "taskArgs": [],
      "projectDir": "${workspaceRoot}"
    }
  ]
}

...and you're good to go! Activate the «Debug and Run» sidebar and select the newly created configuration and hit the green arrow. Your Elixir application should start and you can now enable breakpoints.

moo


You'll only receive email when they publish something new.

More from Kim Grytøyr
All posts