LunarVim (and NeoVim) not recognizing Haskell Language Server in Nix-environment

have a nix working environment (created by my colleague - I have no nix skills myself) for programming in Haskell, and I am using LunarVim as the editor. The environment has been git-cloned from a git repository. It worked nicely for a long time. However, a problem has started to occur:

When starting LunarVim, I get an error message “Client 1 quit with exit code 1 and signal 0” The Language Server status remains at ‘LSP inactive’.

In the lsp-log, the following catches the eye:


[ERROR][2023-11-24 17:03:28] .../vim/lsp/rpc.lua:734	"rpc"	"haskell-language-server-wrapper"	"stderr"	"/$HOME/.local/share/nvim/mason/packages/haskell-language-server/lib/haskell-language-server-2.4.0.0/bin//haskell-language-server-9.2.8: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/librt.so.1)\n
/$HOME/.local/share/nvim/mason/packages/haskell-language-server/lib/haskell-language-server-2.4.0.0/bin//haskell-language-server-9.2.8: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by /nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/libdl.so.2)\n"


I also installed NeoVim, and after a lot of head-scratching, was able to configure it properly for working.
However, it too started failing in the same manner.

I checked the following:

 env | grep LD_

NIX_BUILD_CORES=12
NIX_BUILD_TOP=/run/user/1000

export LD_PRELOAD=/nix/store/x33pcmpsiimxhip52mwxbb5y77dhmb21-glibc-2.37-8/lib/libc.so.6

lvim Auth.hs

Segmentation fault (core dumped)

What can I do to fix the problem?

have a nix working environment

you’ll have to be more precise than that.
Seems like your haskell-language-server cant start.
What if you run lvim from a shell created with nix shell nixpkgs#haskell-language-server. ?

does some nix stuff, but doesn’t seem to change anything - the same error message is received.

The problem appears to be the package manager mason. If I uninstall it,
NeoVim starts working normally. I don’t remember installing it on Lunarvim though,
as I think it is used by default. Hence the situation.

https://www.reddit.com/r/NixOS/comments/13uc87h/masonnvim_broke_on_nixos/

Somebody here claims that nix and mason are fundamentally incompatible, is this true?

if the question is: should I install language servers through mason.nvim or through nix?

The answer I would give is the latter. Make sure the language server is available in the nix environment you are running so it gets picked up by Neovim (hopefully).

It is not really clear to me what you are trying to do. Are you running NixOs or another distribution? How are installed neovim/LSP? From the error:

… /$HOME/.local/share/nvim/mason/…

it seems like you use mason? If you use mason.nvim to install extensions on a NixOs device, it will indeed surely fail, as mason is certainly downloading many pre-built binaries. In that case you might be able to use nix-ld to turn NixOs into a more FHS-like environment, but I’m not sure if it solves all your problems and I would only do that if you are unable to properly package the plugins you use. To me, the cleanest solution would be to use Nix to install both *vim, and the *vim packages, for instance this is explained in the wiki for neovim.

I’ll try to explain more plainly what I’m trying to achieve: My work involves a nix environment (created by my colleague) which I cloned from git. I have no nix skills myself. I would just like to program using my beloved LunarVim. As we’ve already established, the problem comes from incompability of nix and the package manager ‘mason’. I can live with using NeoVim and ‘lazy’ package manager, but I’d prefer LunarVim by a lot.

One solution would be to configure LunarVim to use ‘lazy’ too (instead of mason) - is this possible?

I have no nix skills myself.

Well it sure looks like you will be acquiring some. :tada:

One solution would be to configure LunarVim to use ‘lazy’ too (instead of mason) - is this possible?

Not entirely sure what you mean. I am not using LunarVim and my Neovim config, which is based on the very simple kickstart.nvim, is still using packer. However the guy who started LunarVim has a Discord and I happen to hang out there sometimes. So you can come by there for any LunarVim questions.

The straightforward solution in a NixOS discussion board would be to use nix, since you are already using that, instead of mason, to get your lsp binary available so that Neovim can pick it up. This generally has worked just fine for me. But I am not using Neovim for Haskell with mason.nvim.

Maybe you could ask your co-worker to help you out here? It is most likely just one line of added code to your nix code.

Or you could copy-paste your nix file for your environment here and we can try to do it together. This has the added benefit of increasing your competence should your colleague wish to create more nix environments for you in the near future.

There is also this GitHub issue I found containing more info and workarounds relating to mason and NixOS:

https://github.com/williamboman/mason.nvim/issues/428

Edit: Reading through this again, I think it might really be helpful to have your nix environment to look at more specific things to debug this. Unless that is somehow an internal secret of course.

Edit2: Looking at the error message in more detail, I don’t think there is any incompatibility between Mason and nix in play here. Rather it appears that there is a wrong version of libc or something like this and this conflict with the binary for your haskell-language-server. Again, since this appears to be coming from the nix environment, it would be good to have a look at that.

Thanks, but this does not answer my questions… I can guess but it would significantly help us if you can answer precisely to:

  • which OS are you using? (I guess non-nixos since you say you have no nix skills, but I would expect Package does not run on NixOS · Issue #428 · williamboman/mason.nvim · GitHub not to be a problem outside of NixOs, so can’t be sure…)
  • What is inside the nix environment? Ideally, send us a copy/paste of the nix files.
  • Is LunarVim installed outside via pacman/apt/…, or via nix ? (I expect outside of nix via apt, but not 100% sure)
  • How do you run it precisely? Is LunarVim called from a nix shell, outside etc?
  • Are you fine running LunarVim packaged from nix if it is easier to make it work?

Ideally, if you have a deterministic and clear procedure to follow to get that error, it would be quite useful for other people to help you.

My colleague took a share-screen look at my problem (she lives in a different city,
so we don’t share an office):

As a playground, this nix-environment was used:

The haskell-language server used by the nix-playground:

which haskell-language-server

/nix/store/bi1isf54bfss36nskxayk82n5cv5if3w-haskell-language-server-2.0.0.0
/bin/haskell-language-server

The error message logged in
$HOME/.local/state/lvim/lsp.log :

$HOME/.local/share/lvim/mason/packages/haskell-language-server/lib/haskell-language-server-2.4.0.0/bin//haskell-language-server-9.2.8: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_ABI_DT_RELR'

This turned out to be the root of the problem: Nix and Mason used different versions of the Haskell Language Server, which resulted some whatever conflict. Or possibly there is a problem with Mason and hls 2.4.0.0. Be is as it may, removing hls from Mason solved the problem! In LunarVim:

:MasonUninstall haskell-language-server

So indeed care should be taken not to let Mason install language servers when in nix environment; just having Mason around isn’t the problem.

For the record, I have Linux Mint 21.1. on an AMD Ryzen 7 computer.
And sorry for not being able to describe the problem more promptly,
I just don’t know ‘what is what’ in nix.

2 Likes

Yes, that makes sense. Your nix-shell provides haskell-language-server on its own. And the two installs just conflicted with each other it seems.

Great that you found the solution!