vscode-haskell icon indicating copy to clipboard operation
vscode-haskell copied to clipboard

HLS won't start without all plugins

Open Vlix opened this issue 1 year ago • 2 comments

Your environment

Which OS do you use:

Ubuntu 20.04

Steps to reproduce

  • Install GHCup and use it to:
  • install GHC 9.6.5 and HLS 2.8
  • Start VSCode with a project that uses 9.6.5
  • HLS fails to start saying ~/.ghcup/hls/2.8.0.0/lib/haskell-language-server-2.8.0.0/lib/9.6.5/libHShaskell-language-server-2.8.0.0-l-hls-qualify-imported-names-plugin-{some hash here} doesn't exist
  • LSP dies a horrible death (i.e. doesn't work)
  • Turn off the Qualify Imported Names plugin in all settings
  • Doesn't have any impact; LSP still does nothing

Expected behaviour

Expected verything to "just work" using GHCup/HLS/VSCode in one of the following ways:

  • GHCup/HLS to install the plugins that exist
  • VSCode/HLS to not REQUIRE all plugins to operate

Actual behaviour

Somehow an HLS plugin isn't present and things just don't work.

(On my work laptop it seems to work fine, but that's Ubuntu 22.04, so I'm wondering if the GHCup dist is at fault? But even then, I'd expect everything to at least work without the plugin.)

Vlix avatar May 25 '24 23:05 Vlix

This is what HLS outputs in VSCode (I'm trying to work on the password library):

Found "/home/user/code/password/hie.yaml" for "/home/user/code/password/a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 2.8.0.0 x86_64 ghc-9.2.8
Current directory: /home/user/code/password
Operating system: linux
Arguments: ["--lsp","-d"]
Cradle directory: /home/user/code/password
Cradle type: Stack

Tool versions found on the $PATH
cabal:          3.10.3.0
stack:          2.15.5
ghc:            9.6.5


Consulting the cradle to get project GHC version...
2024-05-26T11:56:18.227161Z | Debug | stack setup --silent
2024-05-26T11:56:18.810768Z | Debug | stack exec ghc -- --numeric-version
Project GHC version: 9.6.5
haskell-language-server exe candidates: ["haskell-language-server-9.6.5","haskell-language-server"]
Launching haskell-language-server exe at:/home/user/.ghcup/tmp/ghcup-ghc-9.6.5_cabal-3.10.3.0_hls-2.8.0.0_stack-2.15.5/haskell-language-server-9.6.5
2024-05-26T11:56:18.849386Z | Debug | stack setup --silent
2024-05-26T11:56:19.676932Z | Debug | stack exec ghc -- -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2024-05-26T11:56:19.703265Z | Debug | stack setup --silent
2024-05-26T11:56:20.364957Z | Debug | stack exec ghc -- --print-libdir
/home/user/.ghcup/hls/2.8.0.0/lib/haskell-language-server-2.8.0.0/bin//haskell-language-server-9.6.5: error while loading shared libraries: libHShaskell-language-server-2.8.0.0-l-hls-qualify-imported-names-plugin-0f10a7046c8a9ea4c27d9088f7c635014f565d4556a323ec980091f117b158eb-ghc9.6.5.so: cannot open shared object file: No such file or directory
[Error - 1:56:21 PM] Connection to server got closed. Server will not be restarted.

(The double slash is also a bit weird in /home/user/.ghcup/hls/2.8.0.0/lib/haskell-language-server-2.8.0.0/bin//haskell-language-server-9.6.5, but probably irrelevant)

Vlix avatar May 26 '24 12:05 Vlix

Hi, thank you for your bug report!

This looks like you are hitting this issue: https://github.com/haskell/haskell-language-server/issues/4142

fendor avatar May 26 '24 12:05 fendor

Ah, I looked around, but I guess I didn't search well enough.

I indeed have ecryptfs on this laptop, but there's no solution or workaround in that issue, so what do I do now? 🤔 I guess I'll try building HLS from source? 🤷

Vlix avatar May 26 '24 13:05 Vlix

Building from source should work indeed, likely you can even use ghcup directly. Try ghcup compile hls --help, that should give you some ideas :)

fendor avatar May 26 '24 14:05 fendor

Welp, no, that doesn't work. Same issue after doing ghcup compile hls --version 2.8.0.0 --ghc 9.6.5

[ cabal ] exe:haskell-language-server from haskell-language-server-2.8.0.0). The failure
[ cabal ] occurred during the final install step. The exception was:
[ cabal ] /home/user/.cabal/store/ghc-9.6.5/package.db/:
[ cabal ] openBinaryTempFileWithDefaultPermissions: invalid argument (File name too
[ cabal ] long)
[ cabal ] 
[ Error ] [GHCup-08841] BuildFailed failed in dir /home/user/.ghcup/tmp/ghcup-050c66b0dd29fe69/haskell-language-server-2.8.0.0: Process "cabal" with arguments ["v2-install",
[ ...   ]                                                                                                                                         "-w",
[ ...   ]                                                                                                                                         "ghc-9.6.5",
[ ...   ]                                                                                                                                         "--install-method=copy",
[ ...   ]                                                                                                                                         "--overwrite-policy=always",
[ ...   ]                                                                                                                                         "--disable-profiling",
[ ...   ]                                                                                                                                         "--disable-tests",
[ ...   ]                                                                                                                                         "--installdir=/home/user/.ghcup/tmp/ghcup-050c66b0dd29fe69/haskell-language-server-2.8.0.0/out/9.6.5",
[ ...   ]                                                                                                                                         "--project-file=cabal.project",
[ ...   ]                                                                                                                                         "exe:haskell-language-server",
[ ...   ]                                                                                                                                         "exe:haskell-language-server-wrapper"] failed with exit code 1.

So HLS via GHCup just doesn't work on ecryptfs systems? :(

Vlix avatar May 26 '24 15:05 Vlix

It looks like it! Then you can still try to install it from Hackage cabal install -w ghc-9.6.5 haskell-language-server and make it available on the $PATH. Make sure to set "haskell.manageHLS": "PATH" or "haskell.serverExecutablePath": <path/to/hls> in vscode.

fendor avatar May 26 '24 16:05 fendor

Just built from source, (git clone repo + stack build) and it seems to work so far. Thanks for the help at least.

Vlix avatar May 26 '24 17:05 Vlix