Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect overlapping instances errors #3694

Open
joyfulmantis opened this issue Jul 8, 2023 · 20 comments
Open

Incorrect overlapping instances errors #3694

joyfulmantis opened this issue Jul 8, 2023 · 20 comments
Labels
GHC issues with particular GHC versions multi-component Issues relating to multi-component support type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@joyfulmantis
Copy link
Collaborator

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)’
@joyfulmantis joyfulmantis added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage labels Jul 8, 2023
@fendor fendor added GHC issues with particular GHC versions and removed status: needs triage labels Jul 12, 2023
@fendor
Copy link
Collaborator

fendor commented Jul 12, 2023

Likely related to the new multiple home units implementation, cc @wz1000

@soulomoon
Copy link
Collaborator

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)

@soulomoon
Copy link
Collaborator

soulomoon commented Dec 25, 2023

Is this one also related?
#3237 #3738

@michaelpj michaelpj added the multi-component Issues relating to multi-component support label Jan 17, 2024
@michaelpj
Copy link
Collaborator

Is this still reproducible?

@soulomoon
Copy link
Collaborator

Shoud be gone if we use multi-repl

@RichardWarfield
Copy link

I'm still seeing this on 2.9.0.0.

@soulomoon
Copy link
Collaborator

soulomoon commented Jul 7, 2024

I'm still seeing this on 2.9.0.0.

Did you try cabal 3.12's multi-repl ?

@konn
Copy link
Collaborator

konn commented Jul 7, 2024

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.

@soulomoon soulomoon reopened this Jul 7, 2024
@soulomoon
Copy link
Collaborator

soulomoon commented Jul 7, 2024

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 ?

@RichardWarfield
Copy link

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

@konn
Copy link
Collaborator

konn commented Jul 7, 2024

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.

@Bodigrim
Copy link
Contributor

Bodigrim commented Jul 7, 2024

Same issue here, even with the very latest GHC 9.10 + Cabal 3.12 + HLS 2.9.

@michaelpj
Copy link
Collaborator

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 using all files (multi-component)" near the start.

@RichardWarfield
Copy link

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.

@michaelpj
Copy link
Collaborator

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.

@RichardWarfield
Copy link

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.

@michaelpj
Copy link
Collaborator

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.

@OlegAlexander
Copy link

I can confirm that upgrading to the latest version of HLS and enabling multipleComponents session loading in VSCode solves this issue.

@RichardWarfield
Copy link

This now works for me as well, with the latest version of lsp-haskell and (setq! lsp-haskell-session-loading "multipleComponents") in my config.

@soulomoon
Copy link
Collaborator

soulomoon commented Oct 28, 2024

I am encountering it again when I am hacking into hie-bios and hls, and loading tons of in files at once using multipleComponents. It only appeared when there are interface files already exist and the load is high. I suspect it have something to do with our compiling caching system for interface and core files.

Nop, using multipleComponents seems fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GHC issues with particular GHC versions multi-component Issues relating to multi-component support type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

8 participants