haskellghcuphaskell-language-server

How to get a working Haskell VS Code setup with ghcup?


I installed Haskell via ghcup

I have installed the HLS via ghcup

I have ghcup set 9.6.1

I have the VS Code extension: https://marketplace.visualstudio.com/items?itemName=haskell.haskell

When I open the project in VS Code I get the following error:

Failed to find the GHC version of this Stack project. Error when calling stack setup --silent

So far I have been using Cabal in the terminal outside of VS Code e.g. cabal build cabal repl etc

I notice that VS Code is trying to use stack... if I try and use Stack in the terminal I get errors like:

$ stack build
Error: [S-9443]
No setup information found for ghc-8.6.5 on your platform.
This probably means a GHC bindist has not yet been added for OS key 'macosx-aarch64'.
Supported versions: ghc-8.10.5, ghc-8.10.6, ghc-8.10.7, ghc-9.0.2, ghc-9.2.1, ghc-9.2.2, ghc-9.2.3, ghc-9.2.4, ghc-9.2.5, ghc-9.2.6, ghc-9.2.7, ghc-9.4.1, ghc-9.4.2, ghc-9.4.3, ghc-9.4.4, ghc-9.6.1

I don't know why Stack wants to use GHC 8.6.5, or if this is related to the problem that VS Code extension is having

No idea really what to do, the instructions are ...minimal https://www.haskell.org/ghcup/install/#vscode-integration


Solution

  • Issue discussed in more detail here: https://github.com/haskell/vscode-haskell/issues/841

    Essentially I had a collection of problems, some because the project I was trying to open was old, and some because I am still finding my way around the ghcup toolchain:

    So a bunch of fixes were needed:

    I do still have "haskell.manageHLS": "GHCup" in my VS Code settings.json, not sure if this is needed or not.