Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElixirLS debugger unexpectedly stops when used with Phoenix and VSCode #185

Closed
rickythefox opened this issue Aug 9, 2019 · 18 comments · Fixed by elixir-lsp/elixir-ls#71
Closed

Comments

@rickythefox
Copy link

rickythefox commented Aug 9, 2019

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)

@h8
Copy link

h8 commented Aug 16, 2019

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

@jhberges
Copy link

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

@lukaszsamson
Copy link
Contributor

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

@h8
Copy link

h8 commented Aug 18, 2019

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.

@jhberges
Copy link

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.

@mattraykowski
Copy link

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.

@jhberges
Copy link

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. 👍

@rickythefox
Copy link
Author

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.

@jhberges
Copy link

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 JakeBecker/vscode-elixir-ls#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. '

@bfcns
Copy link

bfcns commented Aug 29, 2019

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.

@jhberges
Copy link

@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

@huangjimmy
Copy link

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

axelson added a commit to elixir-lsp/elixir-ls that referenced this issue Nov 16, 2019
Ensure debugger process continues to run, adapts to the new behavior in Elixir
1.9 that changed `Mix.Task.run` to return instead of sleeping indefinitely:
elixir-lang/elixir@3673849

- Fixes JakeBecker/elixir-ls#194
- Fixes JakeBecker/elixir-ls#185
@axelson
Copy link

axelson commented Nov 16, 2019

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

@apostrophedottilde
Copy link

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. :)

@dealloc
Copy link

dealloc commented Jan 2, 2020

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

@axelson
Copy link

axelson commented Jan 2, 2020

@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.

@dealloc
Copy link

dealloc commented Jan 2, 2020

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

@JakeBecker
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.