haskellvscode-extensionsghchaskell-stackghcup

Error occured while (re-)installing GHC and setting up the VSCode Haskell Plugin


I was trying to setup the Haskell Plugin for VSCode and I had two seperate problems while trying.

First: The original error I faced while setting up the Haskell Plugin in VSCode was: HLS does not support GHC 9.8.4 yet.

Second: I faced a weird error while installing new GHC versions (or reinstalling old ones via --force). Whenever I installed ghc with ghcup install ghc X.X.X it started installing until [ Info ] Merging file tree from "path_xyz" to "path_zyx". but from then on nothing happend and sometimes I couldn't even exit the process with Ctrl+C

When I encountered the first problem I tried adding this:

"haskell.toolchain": {
        "ghc": "9.10.1",
        "hls": "latest",
        "cabal": "recommended"
    },

to my settings.json

but then I faced a new error:

Failed to find a HLS version for GHC 9.8.4 Executable names we failed to find: haskell-language-server-9.8.4.exe,haskell-language-server.exe

While I tried different ghc versions in order to get the plugin to work I tried installing/reinstalling different GHC versions and therefore encountered the second problem.

I tried GHC 9.10.1 for the first time, I tried reinstalling GHC 9.10.1 via --force and I tried installing GHC 9.8.4 for the first time.

For the first problem I also tried a few other things such as:

My laptop is running on Windows 11 and I've used Powershell to manage my Haskell related installations.

ghcup list gives me the following installations:

IS ghc   9.4.8      recommended,base-4.17.2.1 hls-powered 
I  ghc   9.8.4      base-4.19.2.0             2024-11-27 
I  ghc   9.10.1     base-4.20.0.0             hls-powered 
IS cabal 3.12.1.0   latest,recommended 
IS hls   2.9.0.1    latest,recommended 
IS stack 3.1.1      latest,recommended 
IS ghcup 0.1.30.0   latest,recommended

Solution

  • I had the exact same error and was finally able to solve it myself: You just need to specify a different resolver in the stack.yaml file whose GHC version is supported by the HLS. To do this, compare the pages HLS: GHC version support and Stackage: snapshots and look for a newer supported GHC version. In my case (and yours) that would be lts-22.43. To do this, simply change the snapshot in stack.yaml:

    snapshot: lts-22.43
    

    Hope this solves the problem for you!