haskell-language-server
haskell-language-server copied to clipboard
Incorrect overlapping instances errors
I am getting a bunch of incorrect overlapping instances errors while running HLS HEAD on GHC 9.4 . I imagine it's something to do with the multi-home unit stuff. An example of these errors are:
• Overlapping instances for Ord Priority arising from a use of ‘>=’
Matching instances:
instance Ord Priority
-- Defined at /home/zhangtianci/MySourceCode/haskell-language-server/ghcide/src/Development/IDE/Types/Logger.hs:80:31
instance Ord Priority
-- Defined at /home/zhangtianci/MySourceCode/haskell-language-server/ghcide/src/Development/IDE/Types/Logger.hs:80:31
• In the expression: priority msg >= Info
In the first argument of ‘cfilter’, namely
‘(\ msg -> priority msg >= Info)’
In the second argument of ‘($)’, namely
‘cfilter
(\ msg -> priority msg >= Info)
(cmapWithPrio LogLspServer recorder)’
Likely related to the new multiple home units implementation, cc @wz1000
run in to the same problem
• Overlapping instances for Monad Rules arising from a do statement
Matching instances:
instance Monad Rules
-- Defined at /Users/ares/src/haskell-language-server/hls-graph/src/Development/IDE/Graph/Internal/Types.hs:63:23
instance Monad Rules
-- Defined at /Users/ares/src/haskell-language-server/hls-graph/src/Development/IDE/Graph/Internal/Types.hs:63:23
• In a stmt of a 'do' block:
addIdeGlobal $ GlobalIdeOptions options
In the second argument of ‘($)’, namely
‘do addIdeGlobal $ GlobalIdeOptions options
ofInterestRules (cmapWithPrio LogOfInterest recorder)
fileExistsRules (cmapWithPrio LogFileExists recorder) lspEnv
mainRule’
In a stmt of a 'do' block:
shakeOpen
(cmapWithPrio LogShake recorder) lspEnv defaultConfig plugins
logger debouncer shakeProfiling (optReportProgress options)
(optTesting options) withHieDb hiedbChan (optShakeOptions options)
metrics
$ do addIdeGlobal $ GlobalIdeOptions options
ofInterestRules (cmapWithPrio LogOfInterest recorder)
fileExistsRules (cmapWithPrio LogFileExists recorder) lspEnv
mainRuletypecheck(-Wdeferred-type-errors)
GlobalIdeOptions
Defined at /Users/ares/src/haskell-language-server/ghcide/src/Development/IDE/Core/Shake.hs:400:28 (ghcide-2.5.0.0)
Is this one also related? #3237 #3738
Is this still reproducible?
Shoud be gone if we use multi-repl
I'm still seeing this on 2.9.0.0.
I'm still seeing this on 2.9.0.0.
Did you try cabal 3.12's multi-repl
?
I've been also seeing this with HLS 2.9, Cabal 3.12, 9.4 ≦ GHC ≦ 9.10 even multi-repl enabled, haven't came up with minimal repro though.
I've been also seeing this with HLS 2.9, Cabal 3.12, 9.4 ≦ GHC ≦ 9.10 even multi-repl enabled, haven't came up with minimal repro though.
The error is gone for the HLS codebase with multi-repl enabled, is there another public repo that I can take a look at ?
So I didn't realize that this was something not on by default. Adding multi-repl: True
to my cabal.project
and setting sessionLoading = multipleComponents
in the LSP settings seems to get me further.
But I'm now getting errors like the below in my "lsp-haskell::stderr" buffer (I'm using emacs with lsp-mode):
2024-07-07T10:27:54.490391Z | Info | cabal --builddir=/home/richard/.cache/hie-bios/dist-project-mono-c99a57d181b0c5f31770ad32ba847f6f v2-repl --with-compiler /home/richard/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/richard/.cache/hie-bios/ghc-pkg-affc9b4db595be00dcad4d6d90845282 project-hs
Environment Variables
HIE_BIOS_OUTPUT: /tmp/HIE_BIOS_OUTPUT2845555-0
HIE_BIOS_GHC: /nix/store/fjskwn56niv4fswwfkgqm4c2m70qqvqm-ghc-9.6.6/lib/ghc-9.6.6/bin/ghc-9.6.6
HIE_BIOS_GHC_ARGS: -B/nix/store/skj2sy6hx0cq61bjy58r4nfzcpfghmpy-ghc-shell-for-packages-ghc-9.6.6-env/lib/ghc-9.6.6/lib
Error while expanding response file: /home/richard/.cache/hie-bios/dist-project-mono-c99a57d181b0c5f31770ad32ba847f6f/multi-out-2845758/project-hs-0.1.0.0-inplace: openFile: does not exist (No such file or directory)
The path /home/richard/.cache/hie-bios/dist-project-mono-c99a57d181b0c5f31770ad32ba847f6f/
indeed doens't contain any multi-out-***
directory:
% ls /home/richard/.cache/hie-bios/dist-project-mono-c99a57d181b0c5f31770ad32ba847f6f
build cache packagedb src tmp
Unfortunately I encounter this mainly within closed codebases. I sometimes encounter this in https://github.com/konn/ghc-wasm-earthly , but this repository suffers also mainly from source code plugin bugs and contains ~1000 autogenerated modules, so it might not be so suitable for diagnosing this issue I'm afraid.
Same issue here, even with the very latest GHC 9.10 + Cabal 3.12 + HLS 2.9.
Can I just get everyone to confirm that they're enabling multi-component support as described here? https://well-typed.com/blog/2024/07/hls-multi/
Also, you should be seeing a log like "Loading
I have multi-repl: True
in project.cabal
and have the below in my emacs config:
(add-hook 'lsp-after-initialize-hook
'(lambda ()
(lsp--set-configuration
'(:haskell (:sessionLoading "multipleComponents"))
)))
(The linked source refers to "multiComponent" instead of "multipleComponents" but I think the latter is correct now (HLS complains about the former))
I am not seeing any message like "Loading using all files (multi-component)" in the stderr buffer.
You should see
Load cabal cradle using all files (multi-components)
if it is using multiple units and
Load cabal cradle using single file
otherwise. It's an info level log so it should be there.
OK I see Load cabal cradle using single file
. I also see LSP: set new config: { "sessionLoading": "multipleComponents" }
so I'm not sure what's going on. Perhaps it's not getting set early enough? I followed the pattern for adding extra configuration in the readme for lsp-haskell.
Here's a pastebin for the logs.
The config seems to be being set okay, but then we're still loading using single file mode for some reason? Sometimes we can't because e.g. your cabal version is too old, but I don't see any logs about that so I am currently confused.