1

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:

  • deleting the .stack-work folder in the projects directory twice

    • once opening vscode after using stack setup

    • and once without

  • I tried using ghcup set 9.10.1 but vscode still printed the same error about version 9.8.4

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
2
  • I ran into a similar problem last night after installing the GHC toolchain with ghcup and opening my project (created using stack new myprojectname) in VS Code. Can you check if creating the project using stack new myprojectname --resolver lts-21.25 followed by running stack config set system-ghc true inside the project directory helps? Note that I'm assuming that your system ghc will be 9.4.8, as indicated by your ghcup list output.
    – A.K.
    Commented Dec 23, 2024 at 7:28
  • @A.K. I guess that would work for new projects but as I wanted to keep my already existing project I used Gedankenpolizeis solution proposed in the answer to my original post. Also I think setting the resolver to a supported version should be enough (in case your stack/ghc/hls versions are already configured to match)
    – Hallo5000
    Commented Jan 24 at 14:45

1 Answer 1

1

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!

1
  • Thanks, this solved the problem perfectly For others with the same problem I would suggest when asked if VSCode should install the toolchain to cancel it and do yourself via ghcup. The only issue with this solution is, that it needs to be manually changed for each project after creating it. So do you for some chance know how to create something like a default stack.yaml ?
    – Hallo5000
    Commented Jan 24 at 14:31

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.