简体   繁体   English

`VSCode` 的`Haskell` 扩展不适用于 `Linux`

[英]`Haskell` extension for `VSCode` not working on `Linux`

I installed ghcup and:我安装了ghcup并且:

  • Stack 2.9.1堆栈 2.9.1
  • HLS 1.8.0 HLS 1.8.0
  • cabal 3.6.2阴谋集团 3.6.2
  • GHC 9.2.5 GHC 9.2.5

All of them are the recommended versions(I verified it using ghcup tui ).都是推荐版本(我用ghcup tui验证过)。 Then I installed the Haskell extension in VSCode .然后我在VSCode中安装了Haskell扩展。 Unfortunately, it doesn't work.不幸的是,它不起作用。 I get syntax highlighting (from the Haskell Syntax Highlighting extension, which seems to be automatically installed alongside the Haskell extension) but there is no Intellisense, no code completion, no error detection and no interactive mode ( -->>> evaluation).我得到了语法高亮显示(来自Haskell Syntax Highlighting扩展,它似乎与Haskell扩展一起自动安装)但没有 Intellisense,没有代码完成,没有错误检测,也没有交互模式( -->>>评估)。 I experimented with different folders and haskell files.我尝试了不同的文件夹和 haskell 个文件。 The filetype is correct, because every time I open a .hs file, the Haskell extension checks for updates.文件类型是正确的,因为每次我打开.hs文件时,Haskell 扩展名都会检查更新。 I even installed Codium , because I suspected a fault in VSCode , but it was the same there as well.我什至安装了Codium ,因为我怀疑VSCode有问题,但那里也一样。

The hsl language server doesn't seem to be working in Neovim, either. hsl语言服务器似乎也无法在 Neovim 中运行。 I uninstalled ghcup ( ghcup nuke ) and reinstalled again.我卸载ghcup ( ghcup nuke ) 并再次重新安装。 The result is exactly the same.结果完全一样。 I prepended the PATH and chose vanilla and non-vanilla Stack integration in either installations.我在 PATH 前面添加了PATH并在任一安装中选择了 vanilla 和非 vanilla Stack 集成。

Am I doing something wrong?难道我做错了什么?

OS: Linux Mint on Ubuntu 20.04.1 , kernel 5.15.0-56 .操作系统: Linux Mint on Ubuntu 20.04.1 5.15.0-56

After around 10 tries, I managed to fix the problem.经过大约 10 次尝试,我设法解决了这个问题。 It turned out I had three problems:结果我遇到了三个问题:

  • I had only 12 GB free on my Linux partition, but it seems more are needed.我的 Linux 分区上只有 12 GB 可用空间,但似乎还需要更多空间。 I realised it, when it turned out some haskell-language-server files were missing.当我发现一些haskell-language-server文件丢失时,我意识到了。 I enlarged my Linux partition (something I should have done months ago).我扩大了我的 Linux 分区(我几个月前就应该做的事情)。 The new installation installed all files全新安装安装所有文件
  • The Haskell Language Server HLS was not added to the PATH. Haskell 语言服务器 HLS 未添加到 PATH。 I solved it by putting this snippet in ~/.ghcup/config.yaml :我通过将此代码段放入~/.ghcup/config.yaml来解决它:
  "haskell.serverEnvironment": {
    "PATH": "${HOME}/.ghcup/bin:$PATH"
  }
  • The server was now discovered by the Haskell VS Code extension but crashed 5 times and gave up on trying.服务器现在被Haskell VS Code 扩展发现,但崩溃了 5 次并放弃了尝试。 Restarting it manually didn't help.手动重新启动它没有帮助。 I opened the logs: View -> Output -> Haskell and saw the error:我打开日志: View -> Output -> Haskell并看到错误:
haskell-language-server-wrapper: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by haskell-language-server-wrapper)

It turns out, my Linux Mint distribution uses GLIBC_2.31 , not 2.32 .事实证明,我的 Linux Mint 发行版使用GLIBC_2.31 ,而不是2.32 This is a very important library, which most applications on the system use.这是一个非常重要的库,系统上的大多数应用程序都使用它。 If you are a newbie, it is strongly advised that you DO NOT update it manually.如果您是新手,强烈建议您不要手动更新它。

  • Instead, what I did, was install a version of the HLS , which used GLIBC_2.31 .相反,我所做的是安装一个使用GLIBC_2.31HLS版本。 This problem occured in September and was "fixed" but apparently not very well.这个问题发生在 9 月,并被“修复”,但显然不是很好。 There are two options:有两种选择:
    • download the HLS deb10 version manually (didn't work for me):手动下载HLS deb10版本(对我不起作用):
     ghcup install hls -u https://downloads.haskell.org/~hls/haskell-language-server-1.8.0.0/h
    • download using ghcup tui HLS version 1.7.0.0 (or whatever newest, which uses your glibc version) and a GHC, which supports that particular version of the HLS (in my case 9.0.2 ).使用ghcup tui HLS 版本1.7.0.0 (或使用您的glibc版本的任何最新版本)和支持特定版本 HLS(在我的例子中为9.0.2 )的 GHC 下载。
  • I think it's a good idea to preemptively reinstall the extension, in case it used the PATH to configure the HLS , so that its settings are restored to default.我认为抢先重新安装扩展是个好主意,以防它使用 PATH 配置HLS ,以便将其设置恢复为默认值。 It takes up to 20 seconds to initialize the server, so be patient.初始化服务器最多需要 20 秒,请耐心等待。 You can see what's happening in the Output window and verify there are no more errors.您可以看到Output window 中发生了什么,并验证没有更多错误。

I hope this helps.我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM