elixir-tools / elixir-tools.vscode

Visual Studio Code extension for Elixir
https://marketplace.visualstudio.com/items?itemName=elixir-tools.elixir-tools
Other
87 stars 9 forks source link

nextls doesn't start on NixOS #56

Open elliottneilclark opened 9 months ago

elliottneilclark commented 9 months ago

On a Linux machine configured with NixOS, dynamic loading is different. Because of this it's often not possible to simply download a binary that depends on libc and run it.

This manifests as vscode not starting the nextls binary

[Error - 11:51:56 AM] NextLS client: couldn't create connection to server.
Launching server using command /home/elliott/.cache/elixir-tools/nextls/bin/nextls failed. Error: spawn /home/elliott/.cache/elixir-tools/nextls/bin/nextls ENOENT

Nix provides a utility to change all the loads in place. That seems to get nextls running

steam-run ./nextls
Next LS v0.12.6

The language server for Elixir that just works.

     Author: Mitchell Hanberg
  Home page: https://www.elixir-tools.dev/next-ls
Source code: https://github.com/elixir-tools/next-ls

nextls [flags]

FLAGS

  --stdio             Use stdio as the transport mechanism
  --port <port>       Use TCP as the transport mechanism, with the given port
  --help              Show help
  --version           Show nextls version

It might be possible to detect that vscode is on Nixos and then run steam-run nextls in the extension.

Rust Analyzer also has a similar issue of needing a running process downloaded from the internet. They chose to solve this by having nixos fix up the binary.

https://github.com/rust-lang/rust-analyzer/blob/2b580a1f3c7bf7f2dd6d1462282362b80a6a3d91/editors/code/src/bootstrap.ts#L100C1-L144C2

alissonfpmorais commented 8 months ago

I'm having the same problem here, also I didn't knew about steam-run. Did you managed to get the extension working with it?