elixir-ls icon indicating copy to clipboard operation
elixir-ls copied to clipboard

ElixirLS debugger unexpectedly stops when used with Phoenix and VSCode

Open rickythefox opened this issue 7 years ago • 18 comments

Trying to debug my Phoenix project in VSCode using ElixirLS. The launch config is defined as

{
  "type": "mix_task",
  "name": "mix phx.server",
  "request": "launch",
  "task": "phx.server",
  "projectDir": "${workspaceRoot}"
} 

The debugger starts and displays call stack for a fraction of a second but then immediately stops after "[info] Access TestAppWeb.Endpoint at http://localhost:4000". Has anyone gotten this to work?

Demo: https://i.stack.imgur.com/VMrkG.gif

Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace] Elixir 1.9.1 (compiled with Erlang/OTP 22)

rickythefox avatar Aug 09 '19 09:08 rickythefox

Experiencing exactly the same issues. Looks like it's not related to Phoenix, because I see the same behavior with just mix run command.

h8 avatar Aug 16 '19 18:08 h8

I have a somewhat similar behavior, though the debugger dies with the following error message in my case:

Started ElixirLS debugger
Elixir version: "1.9.1 (compiled with Erlang/OTP 21)"
Erlang version: "22"

13:23:04.326 [info]  Application debugger exited: ElixirLS.Debugger.start(:normal, []) returned an error: shutdown: failed to start child: ElixirLS.Debugger.Server
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function :int.start/0 is undefined (module :int is not available)
            :int.start()
            (debugger) lib/debugger/server.ex:56: ElixirLS.Debugger.Server.init/1
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

jhberges avatar Aug 18 '19 11:08 jhberges

Have you tried disabling phoenix live reload? It's recompiling modules on the fly and my guess is it's interfering with the debugger.

lukaszsamson avatar Aug 18 '19 11:08 lukaszsamson

Have you tried disabling phoenix live reload? It's recompiling modules on the fly and my guess is it's interfering with the debugger.

I'm not using Phoenix at all, and no live reload of any kind, and the issue is still present.

h8 avatar Aug 18 '19 11:08 h8

Have you tried disabling phoenix live reload? It's recompiling modules on the fly and my guess is it's interfering with the debugger.

I am using Phoenix in this project, but only as a pure JSON api.

Disabling the live reloading changed nothing - but thanks for the suggestion.

jhberges avatar Aug 18 '19 11:08 jhberges

Environments:

  • Mac OSX 10.14.5

  • Elixir 1.9.0

  • Erlang/OTP 22

  • Windows 10 w/WSL (Ubuntu 18.04) (and Remote: WSL extension)

  • Elixir 1.8.2 and 1.9.1

  • Erlang/OTP 20 and 22

Steps to repeat:

  1. mix phx.new vscode_test
  2. cd vscode_test
  3. mix deps.get
  4. mix compile
  5. mix test - Just to verify the tests run normally.
  6. code .
  7. Click Debugger
  8. Click Settings and choose Mix Task
  9. Click Settings again and add:
    {
      "type": "mix_task",
      "name": "mix phx.server",
      "request": "launch",
      "projectDir": "${workspaceRoot}",
      "task": "phx.server"
    },
  1. Choose mix phx.server from dropdown and click the Debug/play icon.
  2. Observe it telling you that Phoenix is running but it is not.

mattraykowski avatar Aug 20 '19 18:08 mattraykowski

Well, well, well.

Turns out my variant of the issue was the Ubuntu packaging. The debugger had gone missing in an Erlang/OTP upgrade.

sudo apt install erlang-debugger was my friend, at least. :+1:

jhberges avatar Aug 27 '19 18:08 jhberges

Well, well, well.

Turns out my variant of the issue was the Ubuntu packaging. The debugger had gone missing in an Erlang/OTP upgrade.

sudo apt install erlang-debugger was my friend, at least. 👍

For me erl -s debugger start launches the debugger, so that's probably not the issue here.

rickythefox avatar Aug 27 '19 19:08 rickythefox

I spoke too soon, it would seem. Got distracted and didn't get back to this debugging until now, and now I find my self with https://github.com/JakeBecker/vscode-elixir-ls/issues/120, then the debugger abruptly terminating.

Side note: this is an API Phoenix project, using the Commanded framework. Ubuntu 19.04 on a Thinkpad T470s, everything up to date.

Started ElixirLS debugger
Elixir version: "1.9.1 (compiled with Erlang/OTP 21)"
Erlang version: "22"
[debug] Attempting to start Postgrex
[debug] Successfully started Postgrex (#PID<0.325.0>)
[debug] Attempting to start Postgrex.Notifications
[debug] Successfully started Postgrex.Notifications (#PID<0.336.0>)
[debug] Attempting to start Postgrex
[debug] Successfully started Postgrex (#PID<0.338.0>)
[debug] Subscription "XXXX"@"$all" attempting to connect subscriber #PID<0.428.0>
[debug] Subscription "XXXX"@"$all" attempting to connect subscriber #PID<0.427.0>
[debug] Subscription "XXXX"@"$all" catching-up
[debug] XXXX has successfully subscribed to event store
[debug] Subscription "XXXX"@"$all" catching-up
[debug] XXXX  has successfully subscribed to event store
(a bit of a pause, while the debugger is in starting up mode)
[error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.1-1/lib/elixir/lib/collectable.ex. Function: read_file_info. '
[error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.1-1/lib/elixir/lib/enum.ex. Function: read_file_info. '
[error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.1-1/lib/iex/lib/iex/info.ex. Function: read_file_info. '
[error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.1-1/lib/elixir/lib/inspect.ex. Function: read_file_info. '
[error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.1-1/lib/elixir/lib/list/chars.ex. Function: read_file_info. '
[error] 'File operation error: eacces. Target: /root/deb/elixir_1.9.1-1/lib/elixir/lib/string/chars.ex. Function: read_file_info. '

jhberges avatar Aug 29 '19 19:08 jhberges

same problem here... for the eacces error you can use asdf version of erlang/elixir...

but that does not help with the main problem of this thread.

bfcns avatar Aug 29 '19 19:08 bfcns

@phpcitizen nope - just an observation in case it somehow was related. (though the env-var tricks do not seem to work for me)

Another observation is that Cowboy seems to never start. Starting on the command line Cowboy logs infomessages just after Postgrex. In the elixirls console in vscode, those log messages are never logged:

[info] Running xxx.Endpoint with cowboy 2.6.3 at 0.0.0.0:4000 (http)
[info] Access xxx.Endpoint at http://localhost:4000

jhberges avatar Aug 30 '19 14:08 jhberges

I experience the same too! Hope this issue be resolved soon

huangjimmy avatar Sep 11 '19 20:09 huangjimmy

I just published version 0.2.28 of the ElixirLS fork that solves this issue: https://github.com/elixir-lsp/elixir-ls

axelson avatar Nov 16 '19 18:11 axelson

Well, well, well.

Turns out my variant of the issue was the Ubuntu packaging. The debugger had gone missing in an Erlang/OTP upgrade.

sudo apt install erlang-debugger was my friend, at least. 👍

Thanks! This reminded me that I "upgraded" my macos to Catalina yesterday. I reinstall erlang and elixir and it's all working again and I can debug. :)

apostrophedottilde avatar Dec 27 '19 19:12 apostrophedottilde

@axelson any chance you can PR against this plugin to get this one working again?

dealloc avatar Jan 02 '20 13:01 dealloc

@dealloc A PR hasn't been merged in this repo since march of last year (not including the license PR) so I doubt a PR that I made would be merged.

axelson avatar Jan 02 '20 17:01 axelson

@axelson Ah yes I see, that's rather unfortunate. I installed the fork for now :)

dealloc avatar Jan 02 '20 19:01 dealloc

This project has moved!

It's now being maintained by proactive volunteers from the Elixir community over at elixir-lsp/elixir-ls. Updates will continue to be published from that repo to the original VS Code extension, so no need to switch plugins if you're using VS Code.

To avoid inundating the new maintainers with issues, please verify that your issue persists with the latest version of the extension (which is published from the new repo) before re-filing your issue there.

Thanks for using ElixirLS!

JakeBecker avatar Apr 16 '20 03:04 JakeBecker