ElixirLS (VSCode extension) installation issue on WSL2, Ubuntu

No need to clone it like that. The LS won’t link to precompiled asdf install, but you can tell asdf to build it for you.

Edit: Cached page as original no longer available: Fixing "Go to Definition" for Elixir's standard library | Random Developer's Blog (original: Fixing “Go To Definition” for Elixir’s standard library | Random Developer’s Blog )

It turns out asdf-elixir is using precompiled version when you execute asdf install elixir <version> which does not contain source code. However, if you take any commit reference (SHA string) from Elixir repo and use asdf install elixir ref:<commit_reference>, asdf will actually build it from the source to which that reference points. Each Elixir release is tagged so finding a commit reference for a correct version is pretty straightforward. After that, just as with normal asdf installation, you have to execute asdf global elixir ref:<commit_reference> to set that version as global.

After this is done, go to any project, delete .elixir_ls, deps and _build, run VSCode again and wait for the language server finish its job. Now, “Go to Definition” should work for everything (for the standard library it actually takes a couple of seconds; others should be instant).

4 Likes