emmettng

emmettng

I just started trying Elixir today and configuring the dev environment in vscode and got this error.

Here is some basic information below :

Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:20:20] [ds:20:20:10] [async-threads:1] [jit]
Elixir 1.12.2 (compiled with Erlang/OTP 24)

I created a project following this tutorial https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html

After installing this vscode plugin " ElixirLS: Elixir support and debuggerv0.14.5"

I got this error message.

could not compile dependency :sourceror, “mix compile” failed. You can recompile this dependency with “mix deps.compile sourceror”, update it with “mix deps.update sourceror” or clean it with “mix deps.clean sourceror”
[Error - 21:37:22] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 21:37:22] Connection to server got closed. Server will restart.
true
[Error - 21:37:22] ElixirLS - kv client: couldn’t create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097

I googled similar issues and no solution fixed my problem interestingly, there is no “.elixir_ls/” in the project root.
I think this must be a really trivial mistake and it took me 3 hours

Showing Posts 1 to 10

cloudytoday

cloudytoday

Try creating a dummy project and adding {:sourceror, "~> 0.12.2"} to dependencies, then get and compile it with mix deps.get && mix deps.compile and tell us if it’s successful or not.

emmettng

emmettng OP

Thank you so much for your help.
After adding the dependencies and compiling as instructed

mix deps.get
Resolving Hex dependencies…
Resolution completed in 0.006s
Unchanged:
sourceror 0.12.2

  • Getting sourceror (Hex package)

mix deps.compile
==> sourceror
Compiling 10 files (.ex)
warning: Sourceror.Code.Formatter.to_algebra/2 is undefined (module Sourceror.Code.Formatter is not available or is yet to be defined)
lib/sourceror/code.ex:78: Sourceror.Code.quoted_to_algebra/2

warning: Sourceror.Code.Normalizer.normalize/2 is undefined (module Sourceror.Code.Normalizer is not available or is yet to be defined)
lib/sourceror/code.ex:77: Sourceror.Code.quoted_to_algebra/2

warning: :sourceror_elixir.string_to_tokens/5 is undefined (module :sourceror_elixir is not available or is yet to be defined)
lib/sourceror/code.ex:21: Sourceror.Code.string_to_quoted_with_comments/2

warning: :sourceror_elixir.tokens_to_quoted/3 is undefined (module :sourceror_elixir is not available or is yet to be defined)
lib/sourceror/code.ex:22: Sourceror.Code.string_to_quoted_with_comments/2

warning: :sourceror_errors.parse_error/4 is undefined (module :sourceror_errors is not available or is yet to be defined)
lib/sourceror/code.ex:37: Sourceror.Code.string_to_quoted_with_comments!/2

warning: Mix.Tasks.Format.formatter_for_file/1 is undefined or private. Did you mean one of:

  * formatter_opts_for_file/1
  * formatter_opts_for_file/2

lib/sourceror.ex:921: Sourceror.locals_without_parens/0

Generated sourceror app

I think I’ve added the sourceror successfully, however, I still got the error message :

could not compile dependency :sourceror, “mix compile” failed. You can recompile this dependency with “mix deps.compile sourceror”, update it with “mix deps.update sourceror” or clean it with “mix deps.clean sourceror”
[Error - 00:42:42] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 00:42:42] The ElixirLS - kv server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 00:42:42] ElixirLS - kv client: couldn’t create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 00:42:42] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097

The dummy project is created using

mix new kv

cloudytoday

cloudytoday

I think I’ve added the sourceror successfully, however, I still got the error message

Yes you did, however there’s quite a number of warnings as well as you can see. From the sourceror README it reads that they DO support your version of Elixir and OTP, but as a first poke you could try installing fresher versions of each via ASDF package manager (very convenient and supports a lot of tools other than Elixir/OTP). After removing your old installations of Elixir and Erlang and installing ASDF following the instructions on their website:

asdf plugin-add elixir
asdf plugin-add erlang
asdf install erlang 25.3
asdf install elixir 1.14.4-otp-25
asdf global erlang 25.3
asdf global elixir 1.14.4-otp-25 
tino415

tino415

It looks like elixir-ls don’t even started. I don’t use vs code but maybe you could try to clone and build elixir-ls locally. It is in this repo GitHub - elixir-lsp/elixir-ls: A frontend-independent IDE "smartness" server for Elixir. Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol" · GitHub, for starter maybe just try deps.get, compile and iex -S mix. Maybe even details about your laptop like os and architecture can be useful, If I remember right, vs code elixir-ls plugin is boundling already build version of elixir-ls.

emmettng

emmettng OP

It works now and thanks so much for your help!
There is some other issue I’d like to mention …
After installing asdf

OS:
Linux h 5.19.0-40-generic #41~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 31 16:00:14 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
fish, version 3.3.1

ASDF VERSION:
v0.11.3-0adc6c1

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/me/.asdf

For some reason, most of the files in the folder .asdf/shims folder look like this

exec ./bin/asdf exec “erlc” “$@” # asdf_allow: ’ asdf ’

which actually should be

exec /home/me/.asdf/bin/asdf exec “elixir” “$@” # asdf_allow: ’ asdf ’
apparently, there is no bin folder inside this shims folder…

just cannot believe why this kind of matured toolkit makes this mistake.
probably there is something fundamentally wrong with my OS configuration…

cloudytoday

cloudytoday

Mine point at the correct locations, but I can’t comment on this, I don’t know much about ASDF and bash scripting. Glad to hear it worked out for you!

lukaszsamson

lukaszsamson

ElixirLS Core Team

Why would you include sourceror in your project deps? Btw you are using a not supportd elixir and otp combination. Eithe update elixir o downgrade otp.

la_219

la_219

I have a similar problem (but with a supported version: Elixir 1.13.4 (compiled with Erlang/OTP 24).

It always says the same when starting VS Code.

could not compile dependency :sourceror, “mix compile” failed. You can recompile this dependency with “mix deps.compile sourceror”, update it with “mix deps.update sourceror” or clean it with “mix deps.clean sourceror”

The thing is - I don’t have this dependency in my workspace, never had and I don’t need it. But I cannot clean it. Any restarts, deleting of deps etc. didn’t work. Do you have any other ideas how to solve this?

lukaszsamson

lukaszsamson

ElixirLS Core Team

Do you have hex installed? See ElixirLS - linked_list client: couldn't create connection to server. · Issue #339 · elixir-lsp/vscode-elixir-ls · GitHub
Can you try cleaning up your mix install cache directory (you can get it with Mix.Utils.mix_cache())

linusdm

linusdm

I have the same sourceror warnings in my lsp logs (running in neovim). No matter what folder I remove (including the mix cache directory as you suggested), the warning keeps coming back. But the LSP works, so it’s not breaking anything for me. In addition to the final warning as shown before, I also have several of these warnings preceding:

warning: redefining module Sourceror (current version loaded from ~/.local/share/lvim/mason/packages/elixir-ls/sourceror-0.11.2.ez/sourceror-0.11.2/ebin/Elixir.Sourceror.beam)\n  lib/sourceror.ex:1\n

(this warning is repeated for a few Sourceror modules).

It’s not clear to me, @la_219, what the observed malfunctioning is, except from the warnings.

Where Next? Top

Trending in Questions Top

Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
mandar1045
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
saleyn
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews