VSCode autocomplete doesn't work for mix-created projects

I’ve installed vscode-elixir and autocomplete works as expected when I’m editing single files.

But when I create projects with mix new, the autocomple doesn’t work.

It’s quite weird, when I run code something.ex in the root of the project directory, autocomplete works. But it doesn’t work for mix.exs in the same directory.

Hi @satoru,

The community has rallied behind the ElixirLS extension, which is the most actively maintained. Perhaps see if it serves your purpose?

2 Likes

I’ve tried ElixirLS but it crashes every time with errors like:

[Error - 5:12:50 PM] Connection to server got closed. Server will not be restarted.
[Error - 5:12:50 PM] Request textDocument/documentSymbol failed.

Could you post your setup (OS, versions of Elixir, VS Code, ElixirLS, etc)?

OS: macOS
Started ElixirLS v0.4.0
Elixir version: “1.10.3 (compiled with Erlang/OTP 22)”
Erlang version: "23

It seems that it’s two textDocument/xxx requests that are failing.
I’ve Googled some of the error messages but find nothing useful.
When I googled “ElixirLS crash” I saw someone mentioned that it might be caused by the dependency to something called “dialyzer”. But ElixirLS still crashed even after I disabled “dialyzer” in the configuration.

Thanks for pasting the ‘ElxirLS Copy Debug info’ output.

mix compile works? The project compiles correctly from the command line?

I don’t know what’s happening but after I disabled ElixirLS and reinstall vscode-elixir, autocomplete is working again even for mix projects.

I wouldn’t expect vscode-elixir to work properly on anything newer than elixir 1.5. it uses an over 3 years old elixir_sense dependancy. A lot has changed in elixir internals since then (especially in 1.7 and 1.10).

@satoru Could you post a more complete error log from ElixirLS?. Also how did you install erlang and elixir?
Please note that for ElixirLS to work other extensions may need to be disabled.

1 Like

Thanks for replying.

My Erlang and Elixir are installed with homebrew.

The complete error log:

Started ElixirLS v0.4.0
Elixir version: "1.10.3 (compiled with Erlang/OTP 22)"
Erlang version: "23"

20:59:57.669 [error] GenServer ElixirLS.LanguageServer.Server terminating
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
    (elixir 1.10.3) lib/io.ex:572: IO.chardata_to_string(nil)
    (elixir 1.10.3) lib/path.ex:520: Path.join/2
    (elixir 1.10.3) lib/path.ex:491: Path.join/1
    (language_server 0.4.0) lib/language_server/server.ex:804: ElixirLS.LanguageServer.Server.create_gitignore/1
    (language_server 0.4.0) lib/language_server/server.ex:735: ElixirLS.LanguageServer.Server.set_settings/2
    (language_server 0.4.0) lib/language_server/server.ex:134: ElixirLS.LanguageServer.Server.handle_cast/2
    (stdlib 3.13) gen_server.erl:680: :gen_server.try_dispatch/4
    (stdlib 3.13) gen_server.erl:756: :gen_server.handle_msg/6
Last message: {:"$gen_cast", {:receive_packet, %{"jsonrpc" => "2.0", "method" => "workspace/didChangeConfiguration", "params" => %{"settings" => %{"elixirLS" => %{"dialyzerEnabled" => true, "dialyzerFormat" => "dialyzer", "dialyzerWarnOpts" => [], "fetchDeps" => true, "mixEnv" => "test", "projectDir" => "dialyzer", "suggestSpecs" => true, "trace" => %{"server" => "off"}}}}}}}
State: %ElixirLS.LanguageServer.Server{analysis_ready?: false, awaiting_contracts: [], build_diagnostics: [], build_ref: nil, build_running?: false, 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: nil, load_all_modules?: false, needs_build?: false, project_dir: nil, received_shutdown?: false, requests: %{}, root_uri: "file:///Users/satoru/projects/learn-elixir/trying", settings: nil, source_files: %{}}
[Info  - 8:59:58 PM] Connection to server got closed. Server will restart.
Started ElixirLS v0.4.0
Elixir version: "1.10.3 (compiled with Erlang/OTP 22)"
Erlang version: "23"

20:59:59.124 [error] GenServer ElixirLS.LanguageServer.Server terminating
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
    (elixir 1.10.3) lib/io.ex:572: IO.chardata_to_string(nil)
    (elixir 1.10.3) lib/path.ex:520: Path.join/2
    (elixir 1.10.3) lib/path.ex:491: Path.join/1
    (language_server 0.4.0) lib/language_server/server.ex:804: ElixirLS.LanguageServer.Server.create_gitignore/1
    (language_server 0.4.0) lib/language_server/server.ex:735: ElixirLS.LanguageServer.Server.set_settings/2
    (language_server 0.4.0) lib/language_server/server.ex:134: ElixirLS.LanguageServer.Server.handle_cast/2
    (stdlib 3.13) gen_server.erl:680: :gen_server.try_dispatch/4
    (stdlib 3.13) gen_server.erl:756: :gen_server.handle_msg/6
Last message: {:"$gen_cast", {:receive_packet, %{"jsonrpc" => "2.0", "method" => "workspace/didChangeConfiguration", "params" => %{"settings" => %{"elixirLS" => %{"dialyzerEnabled" => true, "dialyzerFormat" => "dialyzer", "dialyzerWarnOpts" => [], "fetchDeps" => true, "mixEnv" => "test", "projectDir" => "dialyzer", "suggestSpecs" => true, "trace" => %{"server" => "off"}}}}}}}
State: %ElixirLS.LanguageServer.Server{analysis_ready?: false, awaiting_contracts: [], build_diagnostics: [], build_ref: nil, build_running?: false, 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: nil, load_all_modules?: false, needs_build?: false, project_dir: nil, received_shutdown?: false, requests: %{}, root_uri: "file:///Users/satoru/projects/learn-elixir/trying", settings: nil, source_files: %{}}
[Info  - 9:00:00 PM] Connection to server got closed. Server will restart.
Started ElixirLS v0.4.0
Elixir version: "1.10.3 (compiled with Erlang/OTP 22)"
Erlang version: "23"

21:00:00.646 [error] GenServer ElixirLS.LanguageServer.Server terminating
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
    (elixir 1.10.3) lib/io.ex:572: IO.chardata_to_string(nil)
    (elixir 1.10.3) lib/path.ex:520: Path.join/2
    (elixir 1.10.3) lib/path.ex:491: Path.join/1
    (language_server 0.4.0) lib/language_server/server.ex:804: ElixirLS.LanguageServer.Server.create_gitignore/1
    (language_server 0.4.0) lib/language_server/server.ex:735: ElixirLS.LanguageServer.Server.set_settings/2
    (language_server 0.4.0) lib/language_server/server.ex:134: ElixirLS.LanguageServer.Server.handle_cast/2
    (stdlib 3.13) gen_server.erl:680: :gen_server.try_dispatch/4
    (stdlib 3.13) gen_server.erl:756: :gen_server.handle_msg/6
Last message: {:"$gen_cast", {:receive_packet, %{"jsonrpc" => "2.0", "method" => "workspace/didChangeConfiguration", "params" => %{"settings" => %{"elixirLS" => %{"dialyzerEnabled" => true, "dialyzerFormat" => "dialyzer", "dialyzerWarnOpts" => [], "fetchDeps" => true, "mixEnv" => "test", "projectDir" => "dialyzer", "suggestSpecs" => true, "trace" => %{"server" => "off"}}}}}}}
State: %ElixirLS.LanguageServer.Server{analysis_ready?: false, awaiting_contracts: [], build_diagnostics: [], build_ref: nil, build_running?: false, 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: nil, load_all_modules?: false, needs_build?: false, project_dir: nil, received_shutdown?: false, requests: %{}, root_uri: "file:///Users/satoru/projects/learn-elixir/trying", settings: nil, source_files: %{}}
[Info  - 9:00:01 PM] Connection to server got closed. Server will restart.
Started ElixirLS v0.4.0
Elixir version: "1.10.3 (compiled with Erlang/OTP 22)"
Erlang version: "23"

21:00:02.131 [error] GenServer ElixirLS.LanguageServer.Server terminating
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1
    (elixir 1.10.3) lib/io.ex:572: IO.chardata_to_string(nil)
    (elixir 1.10.3) lib/path.ex:520: Path.join/2
    (elixir 1.10.3) lib/path.ex:491: Path.join/1
    (language_server 0.4.0) lib/language_server/server.ex:804: ElixirLS.LanguageServer.Server.create_gitignore/1
    (language_server 0.4.0) lib/language_server/server.ex:735: ElixirLS.LanguageServer.Server.set_settings/2
    (language_server 0.4.0) lib/language_server/server.ex:134: ElixirLS.LanguageServer.Server.handle_cast/2
    (stdlib 3.13) gen_server.erl:680: :gen_server.try_dispatch/4
    (stdlib 3.13) gen_server.erl:756: :gen_server.handle_msg/6
Last message: {:"$gen_cast", {:receive_packet, %{"jsonrpc" => "2.0", "method" => "workspace/didChangeConfiguration", "params" => %{"settings" => %{"elixirLS" => %{"dialyzerEnabled" => true, "dialyzerFormat" => "dialyzer", "dialyzerWarnOpts" => [], "fetchDeps" => true, "mixEnv" => "test", "projectDir" => "dialyzer", "suggestSpecs" => true, "trace" => %{"server" => "off"}}}}}}}
State: %ElixirLS.LanguageServer.Server{analysis_ready?: false, awaiting_contracts: [], build_diagnostics: [], build_ref: nil, build_running?: false, 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: nil, load_all_modules?: false, needs_build?: false, project_dir: nil, received_shutdown?: false, requests: %{}, root_uri: "file:///Users/satoru/projects/learn-elixir/trying", settings: nil, source_files: %{}}
[Warn  - 9:00:02 PM] ** (exit) exited in: GenServer.call(ElixirLS.LanguageServer.JsonRpc, {:packet, %{"id" => 1, "jsonrpc" => "2.0", "method" => "textDocument/documentSymbol", "params" => %{"textDocument" => %{"uri" => "file:///Users/satoru/projects/learn-elixir/trying/mix.exs"}}}}, 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.3) lib/gen_server.ex:1013: GenServer.call/3
    (elixir 1.10.3) lib/stream.ex:441: anonymous fn/4 in Stream.each/2
    (elixir 1.10.3) lib/stream.ex:1449: Stream.do_element_resource/6
    (elixir 1.10.3) lib/stream.ex:1609: Enumerable.Stream.do_each/4
    (elixir 1.10.3) lib/stream.ex:649: Stream.run/1
    (stdlib 3.13) erl_eval.erl:680: :erl_eval.do_apply/6
[Info  - 9:00:03 PM] Connection to server got closed. Server will restart.
[Error - 9:00:03 PM] Request textDocument/documentSymbol failed.
Error: Connection got disposed.
	at Object.dispose (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-languageclient/lib/client.js:74:35)
	at LanguageClient.handleConnectionClosed (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at LanguageClient.handleConnectionClosed (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageWriter.fireClose (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27)
	at Socket.<anonymous> (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.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 - 9:00:03 PM] Request textDocument/codeLens failed.
Error: Connection got disposed.
	at Object.dispose (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-languageclient/lib/client.js:74:35)
	at LanguageClient.handleConnectionClosed (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at LanguageClient.handleConnectionClosed (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageWriter.fireClose (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27)
	at Socket.<anonymous> (/Users/satoru/.vscode/extensions/jakebecker.elixir-ls-0.4.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46)
	at Socket.emit (events.js:203:13)
	at Pipe.<anonymous> (net.js:588:12)

I prefer you to install erlang and elixir using asdf https://github.com/asdf-vm/asdf-elixir and then uninstall ElixirLS and reinstall it. I hop[e this will fix your issue.

Thanks. It looks like your project dir is set to nil for some reason.
It’s crashing in line

Path.join([project_dir, ".elixir_ls", ".gitignore"])

Try setting it to . in extension settings

1 Like

I’ve tried this and it doesn’t work. ElixirLS is still failing with the same error message.

Thanks.
This seems to be relevant to the issue.
After change projectDir to ".", ElixirLS works for all both existing and newly created mix projects. But it still fails when editing single files outside any project, eg, code hello.exs.

1 Like

Does it make any difference if you are inside a VS Code workspace or not? There are a few scenarios I can think of:

  1. You open a single file without opening any folder or workspace in VSC.
  2. You open a folder, but not a workspace, and:
    a. The folder contains the file of interest.
    b. The folder does not contain the file of interest.
  3. You open a VSC workspace and:
    a. The workspace contains the file of interest.
    b. The workspace does not contain the file of interest.

I suspect your troubles may be related to the idea of spawning language servers per workspace. That might affect the scenario where you open a file outside any workspace, or where the file is not in the folder of the current workspace.

Perhaps one of the primary contributors can comment.

1 Like

After some testing I can tell that setting projectDir to "." doesn’t work as intended. It does though when set to "" (despite the validation error).

I’m afraid it’s not fully supported. Doing so currently results in an error

[Error - 9:05:45 AM] No mixfile found in project. To use a subdirectory, set `elixirLS.projectDir` in your settings. Looked for mixfile at "/Users/my_user/elixir_ls_test/mix.exs"

but the completions are still working (at least when running on development version of the extension). As a workaround you can open a mix project and then in the same workspace open the single file from the outside.

Thanks. I’ll just use vim for single files.

1 Like