Description
Your environment
Which OS do you use?
Ubuntu 24.04 + Nix flakes (Nix 2.21.2)
Which version of GHC do you use and how did you install it?
GHC 9.6.4 installed via devenv and Flakes, using languages.haskell.enable = true;
documentation
How is your project built?
I haven't reached a point where that is a concern
Which LSP client (editor/plugin) do you use?
VS Code + vscode-haskell
Which version of HLS do you use and how did you install it?
haskell-language-server version: 2.7.0.0 (GHC: 9.6.4), installed with GHC.
Have you configured HLS in any way (especially: a hie.yaml
file)?
No. However, I configured vscode-haskell to look for HLS on the PATH
and to not try downloading it
Steps to reproduce
Have a Cabal file with a small typo in it, for example:
cabal-version: >=1.10
name: foobar
version: 0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file: LICENSE
-- author:
-- maintainer:
-- copyright:
-- category:
build-type: Simple
extra-source-files: CHANGELOG.md
executable foobar
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends:
base,
modern-uri,
text,
-- hs-source-dirs:
default-language: Haskell2010
extensions:
OverloadedStrings
, FlexibleInstances
, ExtendedDefaultRules
See this error in VSCode:
Failed to find the GHC version of this Cabal project. Error when calling cabal exec -v0 -- ghc --print-libdir
Run haskell-language-server-wrapper --probe-tools
and get something like:
haskell-language-server version: 2.7.0.0 (GHC: 9.6.4) (PATH: /nix/store/z5cmjy6h5bssrj41rykhfzwc8yx48ixn-haskell-language-server-2.7.0.0/bin/haskell-language-server-wrapper)
Tool versions found on the $PATH
cabal: 3.10.2.1
stack: 2.15.3
ghc: 9.6.4
Tool versions in your project
2024-06-25T17:46:25.475821Z | Debug | cabal exec -v0 -- ghc --print-libdir
ghc: Not found
Expected behaviour
Haskell Language Server should return an error message pointing to the actual problem, for example:
Error parsing foobar.cabal:
[ ... error details ... ]
This points the user in the right direction, and it's obvious what they should do to fix the error.
Actual behaviour
The current error message leads the user on a wild goose chase, trying to figure out why ghc
is in their PATH
but not their project. For example, I was hunting down ways to specify a GHC version/path in foobar.cabal
.
The second part of the message points to the source of the error, but the first part is just confusing for the user. I understand the first part isn't wrong, it's what Haskell Language Server was doing when it hit an error condition, but Haskell Language Server could be better about checking for errors in the .cabal
file up-front, and reporting them early.