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

credo-language-server fails to start #67

Closed
barkerja opened this issue Jun 26, 2023 · 24 comments · Fixed by #71
Closed

credo-language-server fails to start #67

barkerja opened this issue Jun 26, 2023 · 24 comments · Fixed by #71

Comments

@barkerja
Copy link

barkerja commented Jun 26, 2023

I just installed v0.2.2. Watching the output for Credo, after my application fully compiles, I see the following error:

[Error - 2:34:25 PM] Stopping server failed
Error: Stopping the server timed out
    at /Users/john/.vscode-insiders/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:150423
[Error - 2:34:25 PM] Stopping server failed
Error: Stopping the server timed out
    at /Users/john/.vscode-insiders/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:150423
[Error - 2:34:25 PM] Stopping server failed
Error: Stopping the server timed out
    at /Users/john/.vscode-insiders/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:150423
[Error - 2:34:25 PM] Stopping server failed
Error: Stopping the server timed out
    at /Users/john/.vscode-insiders/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:150423
[Error - 2:34:25 PM] Client Credo: connection to server is erroring. Shutting down server.
[Error - 2:34:25 PM] Client Credo: connection to server is erroring. Shutting down server.
...

The connection to server is erroring. error continues to repeat indefinitely.

Environment: Elixir 1.14.2 (compiled with Erlang/OTP 24)

If there is more info I can provide, please let me know how to do so! 🙏🏻

@mhanberg
Copy link
Contributor

Can you try it with normal vscode? It looks like you are using the insiders build

also, how long does running mix credo --all --strict take from the command line?

@mhanberg
Copy link
Contributor

Also what version of OTP?

@mhanberg
Copy link
Contributor

mhanberg commented Jun 26, 2023

Also is that all of the output? You said it finished compiling your project, did it ever emit any output about the runtime starting?

@mhanberg mhanberg changed the title Extension fails to start credo-language-server fails to start Jun 26, 2023
@barkerja
Copy link
Author

Can you try it with normal vscode?

I will try this shortly.

also, how long does running mix credo --all --strict take from the command line?

________________________________________________________
Executed in    2.87 secs    fish           external
   usr time   16.25 secs    0.25 millis   16.25 secs
   sys time    1.59 secs    1.88 millis    1.59 secs

Also what version of OTP?

24.3.4.8

Also is that all of the output?

That is all that output I see from the credo output in VSCode.

You said it finished compiling your project, did it ever emit any output about the runtime starting?

Not that I noticed. If it was output somewhere else, I may have missed it.

@barkerja
Copy link
Author

Same exact issue in VSCode 1.79.2

@mhanberg
Copy link
Contributor

I installed those elixir and otp versions and got

** (RuntimeError) no shell process input given for yes?/2
    (mix 1.14.2) lib/mix/shell/process.ex:148: Mix.Shell.Process.yes?/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:256: Mix.Tasks.Deps.Compile.handle_rebar_not_found/1
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:218: Mix.Tasks.Deps.Compile.do_rebar3/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:96: anonymous fn/4 in Mix.Tasks.Deps.Compile.compile/2
    (elixir 1.14.2) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.14.2) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:80: Mix.Tasks.Deps.Compile.compile/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:84: Mix.Tasks.Deps.Loadpaths.deps_check/2
[Error - 3:35:19 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 3:35:19 PM] Connection to server got closed. Server will restart.
true
[Error - 3:35:19 PM] Credo client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
** (RuntimeError) no shell process input given for yes?/2
    (mix 1.14.2) lib/mix/shell/process.ex:148: Mix.Shell.Process.yes?/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:256: Mix.Tasks.Deps.Compile.handle_rebar_not_found/1
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:218: Mix.Tasks.Deps.Compile.do_rebar3/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:96: anonymous fn/4 in Mix.Tasks.Deps.Compile.compile/2
    (elixir 1.14.2) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:80: Mix.Tasks.Deps.Compile.compile/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:84: Mix.Tasks.Deps.Loadpaths.deps_check/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:43: Mix.Tasks.Deps.Loadpaths.run/1
[Error - 3:35:19 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 3:35:19 PM] Connection to server got closed. Server will restart.
true
[Error - 3:35:19 PM] Credo client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
** (RuntimeError) no shell process input given for yes?/2
    (mix 1.14.2) lib/mix/shell/process.ex:148: Mix.Shell.Process.yes?/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:256: Mix.Tasks.Deps.Compile.handle_rebar_not_found/1
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:218: Mix.Tasks.Deps.Compile.do_rebar3/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:96: anonymous fn/4 in Mix.Tasks.Deps.Compile.compile/2
    (elixir 1.14.2) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:80: Mix.Tasks.Deps.Compile.compile/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:84: Mix.Tasks.Deps.Loadpaths.deps_check/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:43: Mix.Tasks.Deps.Loadpaths.run/1
[Error - 3:35:19 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 3:35:19 PM] Connection to server got closed. Server will restart.
true
[Error - 3:35:19 PM] Credo client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:35:19 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
** (RuntimeError) no shell process input given for yes?/2
    (mix 1.14.2) lib/mix/shell/process.ex:148: Mix.Shell.Process.yes?/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:256: Mix.Tasks.Deps.Compile.handle_rebar_not_found/1
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:218: Mix.Tasks.Deps.Compile.do_rebar3/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:96: anonymous fn/4 in Mix.Tasks.Deps.Compile.compile/2
    (elixir 1.14.2) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:80: Mix.Tasks.Deps.Compile.compile/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:84: Mix.Tasks.Deps.Loadpaths.deps_check/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:43: Mix.Tasks.Deps.Loadpaths.run/1
[Error - 3:35:19 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 3:35:19 PM] Connection to server got closed. Server will restart.
true
[Error - 3:35:19 PM] Credo client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:35:19 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
** (RuntimeError) no shell process input given for yes?/2
    (mix 1.14.2) lib/mix/shell/process.ex:148: Mix.Shell.Process.yes?/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:256: Mix.Tasks.Deps.Compile.handle_rebar_not_found/1
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:218: Mix.Tasks.Deps.Compile.do_rebar3/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:96: anonymous fn/4 in Mix.Tasks.Deps.Compile.compile/2
    (elixir 1.14.2) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (mix 1.14.2) lib/mix/tasks/deps.compile.ex:80: Mix.Tasks.Deps.Compile.compile/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:84: Mix.Tasks.Deps.Loadpaths.deps_check/2
    (mix 1.14.2) lib/mix/tasks/deps.loadpaths.ex:43: Mix.Tasks.Deps.Loadpaths.run/1
[Error - 3:35:20 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:35:20 PM] The Credo server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 3:35:20 PM] Credo client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 3:35:20 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 

Probably related to #66

@mhanberg
Copy link
Contributor

can you try running mix local.rebar --force in the terminal and then restart vscode?

@barkerja
Copy link
Author

barkerja commented Jun 26, 2023

can you try running mix local.rebar --force in the terminal and then restart vscode?

After doing that, and watching the credo output, I saw this:

[Credo] LSP Initialized!
[Credo] Booting runtime...
... (compile stuff) ...

Then that output was cleared and the errors listed in my initial post occurred again.

@barkerja
Copy link
Author

I tried clearing out .elixir-tools/_build -- but after initialization/compile, results in the issue.

@mhanberg
Copy link
Contributor

okay, umbrella project?

does your project use any custom checks? any credo plugins or 3rd party checks?

what version of credo?

@mhanberg
Copy link
Contributor

also, it would help if you could share the full output.

@barkerja
Copy link
Author

okay, umbrella project?

Negative

does your project use any custom checks? any credo plugins or 3rd party checks?

.credo.exs configuration:

%{
  configs: [
    %{
      name: "default",
      files: %{
        included: ["lib/", "test/", "config/"],
        excluded: []
      },
      checks: [
        {Credo.Check.Refactor.Nesting, max_nesting: 3},
        {Credo.Check.Refactor.Apply, false},
        {Credo.Check.Refactor.MapInto, false},
        {Credo.Check.Warning.LazyLogging, false},
        {Credo.Check.Design.TagTODO, exit_status: 0}
      ]
    }
  ]
}

what version of credo?

1.6.4

@barkerja
Copy link
Author

also, it would help if you could share the full output.

Which full output are you referring to? The initial LSP initialization bit, or...?

If it's the former, I'm not sure what the best way to capture that is, as those logs are cleared immediately as I begin to receive the Stopping server failed logs.

@mhanberg
Copy link
Contributor

Are you saying that the scrollback doesn't go far enough? hmm

@mhanberg
Copy link
Contributor

Can you try making the following change to your credo config? normally the default config has these exclude patterns in them.

%{
  configs: [
    %{
      name: "default",
      files: %{
        included: ["lib/", "test/", "config/"],
-        excluded: []
+        excluded: [~r"/_build/", ~r"/deps/"]
      },
      checks: [
        {Credo.Check.Refactor.Nesting, max_nesting: 3},
        {Credo.Check.Refactor.Apply, false},
        {Credo.Check.Refactor.MapInto, false},
        {Credo.Check.Warning.LazyLogging, false},
        {Credo.Check.Design.TagTODO, exit_status: 0}
      ]
    }
  ]
}

@mhanberg
Copy link
Contributor

Okay, i was able to reproduce the problem by copying your credo config into a project and using the same credo, elixir, and otp versions.

I will test later tonight to get an exact reason.

Thanks for your patience!

@mhanberg
Copy link
Contributor

And i saw the output log clear itself as well, I understand what you meant now.

@mhanberg mhanberg transferred this issue from elixir-tools/elixir-tools.vscode Jun 26, 2023
@barkerja
Copy link
Author

Thanks @mhanberg. Appreciate your work on these tools.

@barkerja
Copy link
Author

Can you try making the following change to your credo config? normally the default config has these exclude patterns in them.

%{
  configs: [
    %{
      name: "default",
      files: %{
        included: ["lib/", "test/", "config/"],
-        excluded: []
+        excluded: [~r"/_build/", ~r"/deps/"]
      },
      checks: [
        {Credo.Check.Refactor.Nesting, max_nesting: 3},
        {Credo.Check.Refactor.Apply, false},
        {Credo.Check.Refactor.MapInto, false},
        {Credo.Check.Warning.LazyLogging, false},
        {Credo.Check.Design.TagTODO, exit_status: 0}
      ]
    }
  ]
}

I just gave this a try, and had a successful start. So that does seem to be our issue here.

@iautom8things
Copy link
Contributor

Hi, my apologies for commenting on a closed issue! And thank you for all of your work on this project!

I'm having the same issue that @barkerja was having but the solution that worked for him does not appear to work for me.

[Error - 10:37:20 AM] Stopping server failed
Error: Stopping the server timed out
	at /Users/mz/.vscode/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:150423
[Error - 10:37:20 AM] Stopping server failed
Error: Stopping the server timed out
	at /Users/mz/.vscode/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:150423
[Error - 10:37:20 AM] Stopping server failed
Error: Stopping the server timed out
	at /Users/mz/.vscode/extensions/elixir-tools.elixir-tools-0.2.2/dist/extension.js:2:150423
[Error - 10:37:20 AM] Client Credo: connection to server is erroring. Shutting down server.

I'll try to list out all applicable versions:

  • vscode: 1.79.2
  • elixir-tools.vscode: v0.2.2
  • erlang: 24.3.4.8
  • elixir: 1.14.2-otp-24
  • credo: 1.6.4 and 1.7.0

I've tried blowing away .elixir-tools, _build and deps, mix local.hex --force and mix local.rebar --force, mix deps.get and restarting vscode but it yields the same issue.


Also, I may very well be mistaken but it doesn't seem like using the excluded field to exclode _build and deps even though those folders weren't included should do anything.

Mix.install([:credo])

defmodule Test do
  def run do
    not_excluded_config = %Credo.Execution{
      cli_options: %Credo.CLI.Options{path: "."},
      files: %{
        included: ["lib/", "test/", "config/"],
        excluded: []
      }
    }

    excluded_config = %Credo.Execution{
      cli_options: %Credo.CLI.Options{path: "."},
      files: %{
        included: ["lib/", "test/", "config/"],
        excluded: [
          ~r"/_build/",
          ~r"/deps/"
        ]
      }
    }

    excluded_count = excluded_config |> Credo.Sources.find() |> Enum.count()
    not_excluded_count = not_excluded_config |> Credo.Sources.find() |> Enum.count()
    IO.puts("excluded count: #{excluded_count}\nnot excluded count: #{not_excluded_count}")
  end
end

Test.run()

This yields the same result for me.

@mhanberg
Copy link
Contributor

Can you make sure you are running credo-language-server 0.2.0? It should print what version it is in the output panel before you see the timeout errors.

It should auto update if you restart vscode, but I want to make sure.

@iautom8things
Copy link
Contributor

Hmm ... Maybe I wasn't because now it's working. and I do see the credo-language-server 0.2.0 message.

Is the language server doing something different than what credo does, out-of-the-box? It doesn't make sense to me that the _build and deps folders need to be ignored since they weren't included via the included: attribute. The elixir script I included shows what I'm talking about. Credo doesn't attempt to source files from those folders if they aren't included in the included: attribute.

@mhanberg
Copy link
Contributor

That was just a hypothesis.

The fix that I found last night was a timeout. Credo took longer than the configured timeout so I set it to infinity. Unrelated to the config thing.

@iautom8things
Copy link
Contributor

Gotchya! Okay.

So you'd expect this to work with 0.2.0 without the changes to exclude _build and deps?

I am still getting a timeout error if I don't include that change.

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.

3 participants