Debug Plug server in Docker

Hello, I use docker (and docker-compose) to spin up a little Plug webserver, everything works fine but I am having trouble using the debugger.

I tried this launch config:

{
      "type": "mix_task",
      "name": "mix (Default task)",
      "request": "launch",
      "projectDir": "${workspaceRoot}",
      "task": "mix run --no-halt",
      "env": {
        "PORT": 3095
      }
    },

but I got

Process #PID<0.118.0> raised an exception
** (FunctionClauseError) no function clause matching in System.put_env/2
    (elixir 1.11.2) lib/system.ex:552: System.put_env("PORT", 3095)
    (elixir_ls_debugger 0.6.2) lib/debugger/server.ex:581: anonymous fn/2 in ElixirLS.Debugger.Server.set_env_vars/

Not sure I am doing the right thing, any help would be welcome :slight_smile:

The error suggests, that there is something trying to write an integer to the environment, that is nt allowed. The environment is from string to string.

1 Like

Hi @NobbZ thanks for helping out!

So this config worked fine:

    {
      "type": "mix_task",
      "name": "mix (Default task)",
      "request": "launch",
      "projectDir": "${workspaceRoot}",
      "task": "run",
      "taskArgs": [
        "--no-halt"
      ],
      "env": {
        "PORT": "3095",
        "COOKIE": "secret",
        "DB_USER": "postgres",
        "DB_PASSWORD": "postgres",
        "DB_NAME": "webserver",
        "DB_HOST": "localhost",
        "DB_PORT": "5432",
      }
    },