Search code examples
elixirelixir-mix

How to run elixir script through `launch.json` file in vscode?


I want to run script for developing function.

My mirror_a.exs is as follows:

IO.inspect("hellworlda")

In the bash terminal, the command mix run "lib/mirror_a.ex" output is as follows:

macbook:mirror yuchen$ mix run "lib/mirror_a.exs"
"hellworlda"

In the vscode, the launch.json is as follows:

"configurations": [
    {
        "type": "mix_task",
        "request": "launch",
        "name": "mix run",
        "task": "lib/mirror_a.exs",
        "taskArgs": [],
        "projectDir": "${workspaceRoot}"
    }
]

When run debugging mode, no output, why?

enter image description here


Solution

  • The launch.json file should be adjusted as follows:

    {
        "type": "mix_task",
        "request": "launch",
        "name": "mix run",
        "task": "run",
        "taskArgs": ["lib/mirror_a.exs"],
        "projectDir": "${workspaceRoot}"
    },
    

    In addition, the reason of "the output is empty" is that right corner's filter select box. It should be set to related launch.json's part. Otherwise the output may be empty.