Skip to content

Failure after updating OS: can the error log be better? #4779

@tomjaguarpaw

Description

@tomjaguarpaw

I updated my OS, and my linker changed. I knew this meant I had to reinstall GHC so I did so (through GHCup). After all these updates, HLS wasn't working properly. Symptom: no red/green squiggly lines on the various errors. I also thought I should reinstall HLS, which I did. No improvement.

To diagnose I looked at the buffer that Emacs calls *lsp-haskell::stderr*. Here are its contents: https://gist.github.com/tomjaguarpaw/dc103fd01784e0fbf1004523bb65b83c

I saw a lot of lines like this:

2025-12-27T19:18:46.269422Z | Debug | pragmas-suggest: Rule Failed: GhcSession
2025-12-27T19:18:46.269492Z | Debug | retrie: Rule Failed: TypeCheck
2025-12-27T19:18:46.269556Z | Debug | explicit-fields: Rule Failed: CollectRecords
2025-12-27T19:18:46.269620Z | Debug | changeTypeSignature: Rule Failed: GetParsedModule
2025-12-27T19:18:46.269684Z | Debug | overloaded-record-dot: Rule Failed: CollectRecordSelectors
2025-12-27T19:18:46.269755Z | Debug | gadt: Rule Failed: GetParsedModuleWithComments
2025-12-27T19:18:46.269818Z | Debug | importLens: Rule Failed: ImportActions
2025-12-27T19:18:46.269881Z | Debug | qualifyImportedNames: Rule Failed: TypeCheck
2025-12-27T19:18:46.269942Z | Debug | alternateNumberFormat: Rule Failed: CollectLiterals
2025-12-27T19:18:46.270010Z | Debug | pragmas-disable: Rule Failed: GhcSession

Searching for "Rule failed" I found #4034 (comment), and so deleted ~/.cache/ghcide. That didn't help. Luckily ChatGPT gave me something to try

haskell-language-server-wrapper --debug .

That showed an obvious error:

  Failed to run
  ["cabal","v2-repl","/home/tom/Haskell/bluefin/bluefin-examples/src/Bluefin/Examples/Stream/InsideAndOut.hs"]
  in directory "/home/tom/Haskell/bluefin". Consult the logs for full command and error.
  Failed command: cabal
  --builddir=/home/tom/.cache/hie-bios/dist-bluefin-e0a07456644d29ba7cac91a1bc6b2c92 v2-repl
  --with-compiler /home/tom/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg
  /home/tom/.cache/hie-bios/ghc-pkg-144f893acdeed51210386e543bf1db9a
  /home/tom/Haskell/bluefin/bluefin-examples/src/Bluefin/Examples/Stream/InsideAndOut.hs
...
  Cannot find the program 'ld'. User-specified path '/usr/bin/ld.gold' does not refer to an
  executable and the program is not on the system path.

Ah! So the problem was the ~/.cache/hie-bios was stale too. If I'd looked closely enough I would have found #4583 (comment) that would have told me the same thing. Deleting that cache directory fixed the problem 🥳

You can even see that ld.gold is mentioned in Emacs' error log: https://gist.github.com/tomjaguarpaw/dc103fd01784e0fbf1004523bb65b83c#file-lsp-haskell-stderr-L567


My question I want to ask with this issue is: could the error log be better? I found the error log, I looked through it, but it was so verbose I missed the exact root cause that was contained explicitly in that log. There are around 500 lines that occur after the root cause line. Why? If HLS can't build the project shouldn't it just stop there and then, and say so?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions