You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux Mint下VSCode中Haskell Language Server启动崩溃求助

Haskell Language Server (HLS) 启动失败:找不到共享库文件

环境信息

  • 系统:Linux Mint 22.1
  • 工具版本:
    cabal:          3.12.1.0
    stack:          3.3.1
    ghc:            9.4.8
    hls:            2.10.0.0
    

问题描述

所有Haskell文件均会触发该问题,与项目无关。HLS启动时提示找不到指定的共享库文件,多次重启进程后停止。已尝试卸载重装ghc、ghcup及相关工具,问题仍未解决。

错误日志

Project GHC version: 9.4.8
haskell-language-server exe candidates: ["haskell-language-server-9.4.8","haskell-language-server"]
Launching haskell-language-server exe at:/home/milkski/.ghcup/bin/haskell-language-server-9.4.8
2025-04-25T10:24:22.867221Z | Debug | ghc -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2025-04-25T10:24:22.920036Z | Debug | ghc --print-libdir
/home/milkski/.ghcup/hls/2.10.0.0/lib/haskell-language-server-2.10.0.0/bin//haskell-language-server-9.4.8: error while loading shared libraries: libHShaskell-language-server-2.10.0.0-l-hls-qualify-imported-names-plugin-4aafd09cc1e098816180592f7a47a048217af31de6fbde6299cb9c7fb29f5828-ghc9.4.8.so: cannot open shared object file: No such file or directory
[Error - 11:24:24] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 11:24:24] Connection to server got closed. Server will restart.
true
[Error - 11:24:24] Haskell (intro-2-haskell-module) client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 11:24:24] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 11:24:24] Server process exited with code 127.
No 'hie.yaml' found. Try to discover the project type!

解决方案尝试

1. 验证共享库是否存在

先确认报错中的库文件是否真的缺失:

find /home/milkski/.ghcup/hls/2.10.0.0 -name "libHShaskell-language-server-2.10.0.0-l-hls-qualify-imported-names-plugin*ghc9.4.8.so"

如果无输出,说明HLS安装不完整,重新安装对应版本:

ghcup install hls 2.10.0.0 --ghc 9.4.8

2. 修复GHCup工具链

执行GHCup自检命令排查环境问题:

ghcup doctor

根据自检提示修复后,重新设置工具链版本:

ghcup set hls 2.10.0.0
ghcup set ghc 9.4.8

3. 配置共享库搜索路径

将HLS的库目录添加到系统共享库搜索路径:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/milkski/.ghcup/hls/2.10.0.0/lib/haskell-language-server-2.10.0.0/lib/x86_64-linux-ghc-9.4.8"

可将此命令添加到~/.bashrc或~/.zshrc中,确保终端启动时自动生效。

4. 手动编译HLS(备选方案)

若GHCup安装的HLS存在损坏,尝试手动编译对应版本:

git clone https://github.com/haskell/haskell-language-server.git
cd haskell-language-server
git checkout 2.10.0.0
cabal install --overwrite-policy=always --ghc=9.4.8

编译完成后,将生成的可执行文件路径添加到环境变量PATH中。

内容的提问来源于stack exchange,提问作者Milkski

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 08:18:28