ElixirLS unable to start debugger in VS nif_not_loaded

Hello everibady,

I’m triing to run phoenix app in debug mode in visual studio and I keep getting this error

(Debugger) Task failed because an exception was raised:
    ** (Mix.Error) Could not start application app: App.Application.start(:normal, []) returned an error: shutdown: failed to start child: App.Endpoint
    ** (EXIT) an exception was raised:
        ** (ErlangError) Erlang error: {:nif_not_loaded, :module, :crypto, :line, 1344}
            :erlang.nif_error({:nif_not_loaded, :module, :crypto, :line, 1344})
            (crypto 4.6.5) crypto.erl:466: :crypto.nif_stub_error/1
            (crypto 4.6.5) crypto.erl:1340: :crypto.strong_rand_bytes/1
            (phoenix 1.5.4) Elixir.Phoenix.Endpoint.Supervisor.erl:81: Phoenix.Endpoint.Supervisor.init/1
        (mix 1.10.4) lib/mix.ex:392: Mix.raise/1
        (elixir 1.10.4) lib/enum.ex:783: Enum."-each/2-lists^foreach/1-0-"/2
        (elixir 1.10.4) lib/enum.ex:783: Enum.each/2
        (mix 1.10.4) lib/mix/tasks/app.start.ex:106: Mix.Tasks.App.Start.start/3
        (mix 1.10.4) lib/mix/tasks/app.start.ex:91: Mix.Tasks.App.Start.run/1
        (mix 1.10.4) lib/mix/task.ex:330: Mix.Task.run_task/3
        (mix 1.10.4) lib/mix/tasks/run.ex:128: Mix.Tasks.Run.run/5
        (mix 1.10.4) lib/mix/tasks/run.ex:85: Mix.Tasks.Run.run/1
        (mix 1.10.4) lib/mix/task.ex:330: Mix.Task.run_task/3
        (elixir_ls_debugger 0.6.0) lib/debugger/server.ex:658: ElixirLS.Debugger.Server.launch_task/2

I’m triing to start task mix -S phx.server, but same result I get when triing to start mix (Default task) from config

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "mix_task",
      "name": "mix (Default task)",
      "request": "launch",
      "projectDir": "${workspaceRoot}"
    },
    {
      "type": "mix_task",
      "name": "mix -S phx.server",
      "request": "launch",
      "projectDir": "${workspaceRoot}"
    },
    {
      "type": "mix_task",
      "name": "mix test",
      "request": "launch",
      "task": "test",
      "taskArgs": [
        "--trace"
      ],
      "startApps": true,
      "projectDir": "${workspaceRoot}",
      "requireFiles": [
        "test/**/test_helper.exs",
        "test/**/*_test.exs"
      ]
    }
  ]
}

anybody managed to get it work?

1 Like

NIFs cannot be run in interpreted mode. You need to exclude them with "excludeModules": [":my_nif", "My.OtherNif"]. Look for warnings Module x cannot be interpreted. Consider adding it to excludeModules`.

4 Likes

Thank you, that worked :slight_smile: