ElixirLS Keep Crashing in vs-code

Error Log Output:

Started ElixirLS v0.5.0
Elixir version: "1.10.4 (compiled with Erlang/OTP 21)"
Erlang version: "23"
ElixirLS compiled with Elixir 1.7.4 and erlang 20
MIX_ENV: test
MIX_TARGET: 
[Info  - 5:28:41 pm] Compile took 572 milliseconds
[Info  - 5:28:41 pm] [ElixirLS WorkspaceSymbols] Indexing...
[Info  - 5:28:41 pm] [ElixirLS Dialyzer] Checking for stale beam files
[Info  - 5:28:41 pm] [ElixirLS WorkspaceSymbols] Module discovery complete
[Info  - 5:28:41 pm] [ElixirLS WorkspaceSymbols] 20 callbacks added to index
[Info  - 5:28:41 pm] [ElixirLS Dialyzer] Found 0 changed files in 62 milliseconds
[Info  - 5:28:41 pm] [ElixirLS Dialyzer] Analyzing 0 modules: []
[Info  - 5:28:41 pm] [ElixirLS Dialyzer] Analysis finished in 220 milliseconds
[Info  - 5:28:41 pm] [ElixirLS WorkspaceSymbols] 232 modules added to index
[Info  - 5:28:41 pm] Dialyzer analysis is up to date
[Info  - 5:28:42 pm] [ElixirLS Dialyzer] Writing manifest...
[Info  - 5:28:43 pm] [ElixirLS WorkspaceSymbols] 300 types added to index
[Info  - 5:28:44 pm] [ElixirLS Dialyzer] Done writing manifest in 2983 milliseconds.
[Info  - 5:28:48 pm] [ElixirLS WorkspaceSymbols] 4546 functions added to index
MIX_ENV: test
MIX_TARGET: 
[Info  - 5:28:50 pm] Compile took 238 milliseconds
[Info  - 5:28:50 pm] [ElixirLS WorkspaceSymbols] Updating index...
[Info  - 5:28:50 pm] [ElixirLS Dialyzer] Checking for stale beam files
[Info  - 5:28:50 pm] [ElixirLS WorkspaceSymbols] 0 modules need reindexing
[Info  - 5:28:50 pm] [ElixirLS WorkspaceSymbols] 0 modules added to index
[Info  - 5:28:50 pm] [ElixirLS WorkspaceSymbols] 0 functions added to index
[Info  - 5:28:50 pm] [ElixirLS WorkspaceSymbols] 0 types added to index
[Info  - 5:28:50 pm] [ElixirLS WorkspaceSymbols] 0 callbacks added to index
[Info  - 5:28:50 pm] [ElixirLS Dialyzer] Found 0 changed files in 29 milliseconds
[Info  - 5:28:50 pm] [ElixirLS Dialyzer] Analyzing 0 modules: []
[Info  - 5:28:50 pm] [ElixirLS Dialyzer] Analysis finished in 39 milliseconds
[Info  - 5:28:50 pm] Dialyzer analysis is up to date
MIX_ENV: test
MIX_TARGET: 

17:28:51.898 [error] GenServer ElixirLS.LanguageServer.Server terminating
** (Mix.Error) Unknown dependency :ecto_sql given to :import_deps in the formatter configuration. The dependency is not listed in your mix.exs for environment :test
    (mix 1.10.4) lib/mix.ex:392: Mix.raise/1
    (mix 1.10.4) lib/mix/tasks/format.ex:246: anonymous fn/3 in Mix.Tasks.Format.eval_deps_opts/2
    (elixir 1.10.4) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (mix 1.10.4) lib/mix/tasks/format.ex:245: Mix.Tasks.Format.eval_deps_opts/2
    (mix 1.10.4) lib/mix/tasks/format.ex:201: anonymous fn/5 in Mix.Tasks.Format.eval_deps_and_subdirectories/4
    (mix 1.10.4) lib/mix/tasks/format.ex:276: anonymous fn/2 in Mix.Tasks.Format.eval_subs_opts/3
    (elixir 1.10.4) lib/enum.ex:1094: anonymous fn/3 in Enum.flat_map_reduce/3
    (elixir 1.10.4) lib/enum.ex:3686: Enumerable.List.reduce/3
Last message: {:"$gen_cast", {:receive_packet, %{"id" => 9, "jsonrpc" => "2.0", "method" => "textDocument/completion", "params" => %{"context" => %{"triggerKind" => 3}, "position" => %{"character" => 44, "line" => 69}, "textDocument" => %{"uri" => "file:///home/supriyo/dev/phoenix_projects/crm_notification/test/crm_notification/customers_test.exs"}}}}}
State: %ElixirLS.LanguageServer.Server{analysis_ready?: false, awaiting_contracts: [{{#PID<0.470.0>, #Reference<0.2850066277.2806513666.35501>}, "file:///home/supriyo/dev/phoenix_projects/crm_notification/test/crm_notification/customers_test.exs"}, {{#PID<0.349.0>, #Reference<0.2850066277.2806513666.28787>}, "file:///home/supriyo/dev/phoenix_projects/crm_notification/test/crm_notification/customers_test.exs"}], build_diagnostics: [], build_ref: #Reference<0.2850066277.2806513666.35516>, build_running?: true, client_capabilities: %{"textDocument" => %{"codeAction" => %{"codeActionLiteralSupport" => %{"codeActionKind" => %{"valueSet" => ["", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports"]}}, "dynamicRegistration" => true, "isPreferredSupport" => true}, "codeLens" => %{"dynamicRegistration" => true}, "colorProvider" => %{"dynamicRegistration" => true}, "completion" => %{"completionItem" => %{"commitCharactersSupport" => true, "deprecatedSupport" => true, "documentationFormat" => ["markdown", "plaintext"], "preselectSupport" => true, "snippetSupport" => true, "tagSupport" => %{"valueSet" => [1]}}, "completionItemKind" => %{"valueSet" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, "contextSupport" => true, "dynamicRegistration" => true}, "declaration" => %{"dynamicRegistration" => true, "linkSupport" => true}, "definition" => %{"dynamicRegistration" => true, "linkSupport" => true}, "documentHighlight" => %{"dynamicRegistration" => true}, "documentLink" => %{"dynamicRegistration" => true, "tooltipSupport" => true}, "documentSymbol" => %{"dynamicRegistration" => true, "hierarchicalDocumentSymbolSupport" => true, "symbolKind" => %{"valueSet" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, "foldingRange" => %{"dynamicRegistration" => true, "lineFoldingOnly" => true, "rangeLimit" => 5000}, "formatting" => %{"dynamicRegistration" => true}, "hover" => %{"contentFormat" => ["markdown", "plaintext"], "dynamicRegistration" => true}, "implementation" => %{"dynamicRegistration" => true, "linkSupport" => true}, "onTypeFormatting" => %{"dynamicRegistration" => true}, "publishDiagnostics" => %{"relatedInformation" => true, "tagSupport" => %{"valueSet" => [1, 2]}, "versionSupport" => false}, "rangeFormatting" => %{"dynamicRegistration" => true}, "references" => %{"dynamicRegistration" => true}, "rename" => %{"dynamicRegistration" => true, "prepareSupport" => true}, "selectionRange" => %{"dynamicRegistration" => true}, "signatureHelp" => %{"contextSupport" => true, "dynamicRegistration" => true, "signatureInformation" => %{"documentationFormat" => ["markdown", "plaintext"], "parameterInformation" => %{"labelOffsetSupport" => true}}}, "synchronization" => %{"didSave" => true, "dynamicRegistration" => true, "willSave" => true, "willSaveWaitUntil" => true}, "typeDefinition" => %{"dynamicRegistration" => true, "linkSupport" => true}}, "window" => %{"workDoneProgress" => true}, "workspace" => %{"applyEdit" => true, "configuration" => true, "didChangeConfiguration" => %{"dynamicRegistration" => true}, "didChangeWatchedFiles" => %{"dynamicRegistration" => true}, "executeCommand" => %{"dynamicRegistration" => true}, "symbol" => %{"dynamicRegistration" => true, "symbolKind" => %{"valueSet" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, "workspaceEdit" => %{"documentChanges" => true, "failureHandling" => "textOnlyTransactional", "resourceOperations" => ["create", "rename", "delete"]}, "workspaceFolders" => true}}, dialyzer_diagnostics: [], dialyzer_sup: #PID<0.125.0>, load_all_modules?: false, needs_build?: false, project_dir: "/home/supriyo/dev/phoenix_projects/crm_notification", received_shutdown?: false, requests: %{8 => #PID<0.470.0>}, root_uri: "file:///home/supriyo/dev/phoenix_projects/crm_notification", server_instance_id: "zfmoIDr4kUwoAFRNKk0HFnhqyVuLFGY-", settings: %{"dialyzerEnabled" => true, "dialyzerFormat" => "dialyxir_long", "dialyzerWarnOpts" => [], "fetchDeps" => true, "mixEnv" => "test", "mixTarget" => "", "projectDir" => "", "suggestSpecs" => true, "trace" => %{"server" => "off"}}, source_files: %{"file:///home/supriyo/dev/phoenix_projects/crm_notification/test/crm_notification/accounts_test.exs" => %ElixirLS.LanguageServer.SourceFile{dirty?: false, text: "defmodule CrmNotification.AccountsTest do\n  use CrmNotification.DataCase\n\n  alias Ecto.Changeset\n  alias CrmNotification.{Accounts, Accounts.User}\n\n  @valid_attrs %{\n    email: \"user@example.com\",\n    name: \"Example User\",\n    password: \"password\",\n    password_confirmation: \"password\",\n    role: \"staff\"\n  }\n\n  @update_attrs %{\n    email: \"test_user2@crm.com\",\n    name: \"test_user2\",\n    password: \"password1\",\n    password_confirmation: \"password1\",\n    role: \"admin\"\n  }\n\n  @invalid_attrs %{\n    email: \"invalid\",\n    name: \"\",\n    password: \"\",\n    password_confirmation: \"\",\n    role: \"invalid\"\n  }\n\n  describe \"list_user/0\" do\n    test \"returns all users\" do\n      user1 = insert!(:user)\n      user2 = insert!(:user)\n\n      user_list = Accounts.list_users()\n\n      id_list = Enum.map(user_list, fn %{id: id} -> id end)\n      assert id_list == Enum.sort(id_list)\n      assert user_list = [user1, user2]\n    end\n  end\n\n  describe \"get_user/1\" do\n    test \"returns the user with valid user id\" do\n      user = insert!(:user)\n      assert Accounts.get_user(user.id) == user\n    end\n\n    test \"returns nil with invalid user id\" do\n      refute Accounts.get_user(-1)\n    end\n  end\n\n  describe \"get_user!/1\" do\n    test \"returns the user with valid user id\" do\n      user = insert!(:user)\n      assert Accounts.get_user!(user.id) == user\n    end\n\n    test \"get_user!/1 raise Ecto.NoResultsError with invalid user id\" do\n      assert_raise Ecto.NoResultsError, fn ->\n        Accounts.get_user!(1)\n      end\n    end\n  end\n\n  describe \"get_user_by_email/1\" do\n    test \"returns the user with valid user email\" do\n      user = insert!(:user)\n      assert Accounts.get_user_by_email(user.email) == user\n    end\n\n    test \"get_user_by_email/1 returns nil with invalid user id\" do\n      refute Accounts.get_user_by_email(@invalid_attrs.email)\n    end\n  end\n\n  describe \"get_user_by_email_and_password/1\" do\n    test \"returns the user with valid user email and password combination\" do\n      user = insert!(:user)\n\n      assert Accounts.get_user_by_email_and_password(user.email, @valid_attrs.password) == user\n    end\n\n    test \"get_user_by_email_and_password/1 returns nil with invalid password\" do\n      insert!(:user, @valid_attrs)\n\n      refute Accounts.get_user_by_email_and_pa (truncated)
[Warn  - 5:28:52 pm] ** (exit) exited in: GenServer.call(ElixirLS.LanguageServer.JsonRpc, {:packet, %{"jsonrpc" => "2.0", "method" => "$/cancelRequest", "params" => %{"id" => 8}}}, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir 1.10.4) lib/gen_server.ex:1013: GenServer.call/3
    (elixir 1.10.4) lib/stream.ex:441: anonymous fn/4 in Stream.each/2
    (elixir 1.10.4) lib/stream.ex:1449: Stream.do_element_resource/6
    (elixir 1.10.4) lib/stream.ex:1609: Enumerable.Stream.do_each/4
    (elixir 1.10.4) lib/stream.ex:649: Stream.run/1
    (stdlib 3.13) erl_eval.erl:680: :erl_eval.do_apply/6
[Error - 5:28:52 pm] Connection to server got closed. Server will not be restarted.
[Error - 5:28:52 pm] Request textDocument/codeLens failed.
Error: Connection got disposed.
    at Object.dispose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/main.js:904:25)
    at Object.dispose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:74:35)
    at LanguageClient.handleConnectionClosed (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:2309:42)
    at LanguageClient.handleConnectionClosed (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/main.js:155:15)
    at closeHandler (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:2296:18)
    at CallbackList.invoke (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
    at closeHandler (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/main.js:240:26)
    at CallbackList.invoke (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
    at StreamMessageWriter.fireClose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27)
    at Socket.<anonymous> (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46)
    at Socket.emit (events.js:203:13)
    at Pipe.<anonymous> (net.js:588:12)
[Error - 5:28:52 pm] Request textDocument/completion failed.
Error: Connection got disposed.
    at Object.dispose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/main.js:904:25)
    at Object.dispose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:74:35)
    at LanguageClient.handleConnectionClosed (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:2309:42)
    at LanguageClient.handleConnectionClosed (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/main.js:155:15)
    at closeHandler (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:2296:18)
    at CallbackList.invoke (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
    at closeHandler (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/main.js:240:26)
    at CallbackList.invoke (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
    at StreamMessageWriter.fireClose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27)
    at Socket.<anonymous> (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46)
    at Socket.emit (events.js:203:13)
    at Pipe.<anonymous> (net.js:588:12)
[Error - 5:28:52 pm] Request textDocument/codeLens failed.
Error: Connection got disposed.
    at Object.dispose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/main.js:904:25)
    at Object.dispose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:74:35)
    at LanguageClient.handleConnectionClosed (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:2309:42)
    at LanguageClient.handleConnectionClosed (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/main.js:155:15)
    at closeHandler (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-languageclient/lib/client.js:2296:18)
    at CallbackList.invoke (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
    at closeHandler (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/main.js:240:26)
    at CallbackList.invoke (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
    at StreamMessageWriter.fireClose (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27)
    at Socket.<anonymous> (/home/supriyo/.vscode/extensions/jakebecker.elixir-ls-0.5.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46)
    at Socket.emit (events.js:203:13)
    at Pipe.<anonymous> (net.js:588:12)
1 Like

Do you have ecto_sql as a direct or indirect dependency? You can check mix.exs or mix.lock.

Is this by any chance an umbrella project where this happens?

It is not an Umbrella project.

Yes, I had ecto_sql in my mix dependencies.

I’ve fixed a lot of problems with ElixirLS by deleting the .elixir_ls folder as described here. They usually happen after ElixirLS gets updated.

2 Likes

Can I stop the auto-update of the ElixirLS extension, if that may resolve the issue. Or do you know which version is the stable one?

I’m experiencing the same issue. This seems to have started with a recent update. It bites me pretty hard after switching branches with different deps. Of course, a simple rm -rf ./.elixir_ls fixes this issue. But the 3-5 minutes to rebuild the project for the “special” ElixirLS build directory is a drag.

It is definitely a hinderance. But it is something I’ve learned to live with for the immense productivity boost I get with this tool.

Aside: I hate that auto-complete stopped working with underscores.

Example:

In a guard, I used to be able to type isbin, hit tab and it would autocomplete is_binary. Now after typing is, if I don’t specify _, I lose all guidance. That is also a drag :slight_smile:

1 Like

That was changed in: Remove keywords from completions by axelson · Pull Request #259 · elixir-lsp/elixir-ls · GitHub

The reason was to avoid some very bad completions, such as:
82835207-10d99c80-9e5f-11ea-82b1-b745707ecf74

We would accept a PR that makes the isIncomplete: true setting configurable.

1 Like

Is there something particular with umbrella projects? I’m currently working on an umbrella application and I get that same output message "ElixirLS has crashed" at least 20 times a day, it is driving me nuts.

1 Like

Yes. The formatter is not picking the correct project root, and that causes issues like this.

So I’m supposed to change the project direction for the extension’s configuration every time I work on different umbrellas?

Under most circumstances it should be set to empty string

This comment save my times. Thanks you so much @factoryd