haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.65k stars 354 forks source link

Problem with multilibraries hierarchy: "It may not be listed in your .cabal file!" #4010

Closed teto closed 7 months ago

teto commented 7 months ago

Your environment

I've forked selda (an abstraction layer around postgres/sqlite) to add a feature, and tried adding HLS support. If I git clone https://github.com/teto/selda.git -b array, then run nix develop , haskell-language-server is lost for some reason.

selda on  array via λ lts-18.28 via ❄️  IMPURE (ghc96-haskell-env-env) 
❌130 ❯ haskell-language-server selda/src/Database/Selda/SqlType.hs
2024-01-23T14:57:52.600979Z | Info | haskell-language-server version: 2.5.0.0 (GHC: 9.6.3) (PATH: /nix/store/28rqr38lzb9yf4zxl3xcjm7yvid8i03x-haskell-language-server-2.5.0.0/bin/.haskell-language-server-9.6.3-unwrapped)
2024-01-23T14:57:52.601649Z | Info | Directory: /home/teto/selda
2024-01-23T14:57:52.601799Z | Info | Logging heap statistics every 60.00s
 ghcide setup tester in /home/teto/selda.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /home/teto/selda
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  ()

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2024-01-23T14:57:52.605744Z | Info | Cradle path: selda/src/Database/Selda/SqlType.hs
2024-01-23T14:57:52.605824Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for selda/src/Database/Selda/SqlType.hs.
Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
2024-01-23T14:57:52.607460Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2024-01-23T14:57:52.607846Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File:     /home/teto/selda/selda/src/Database/Selda/SqlType.hs
Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DiagnosticSeverity_Error
Message: 
  Loading the module '/home/teto/selda/selda/src/Database/Selda/SqlType.hs' failed.

  It may not be listed in your .cabal file!
  Perhaps you need to add `SqlType` to other-modules or exposed-modules.

  For more information, visit:
  https://cabal.readthedocs.io/en/3.4/developing-packages.html#modules-included-in-the-package

  "./ChangeLog.hs" - Cabal {component = Just "selda-build-tools:exe:selda-changelog"}
Files that failed:
 * /home/teto/selda/selda/src/Database/Selda/SqlType.hs

Completed (0 files worked, 1 file failed)

Perhaps you need to add SqlType to other-modules or exposed-modules.

The module exists in exposed-modules though ?

Which OS do you use? nixos

Which version of GHC do you use and how did you install it? 9.6.3 from nixpkgs

How is your project built (alternative: link to the project)? cabal

Which LSP client (editor/plugin) do you use? neovim+haskell-tools.nvim

Which version of HLS do you use and how did you install it?

$ haskell-language-server --version
haskell-language-server version: 2.5.0.0 (GHC: 9.6.3) (PATH: /nix/store/28rqr38lzb9yf4zxl3xcjm7yvid8i03x-haskell-language-server-2.5.0.0/bin/.haskell-language-server-9.6.3-unwrapped)

Have you configured HLS in any way (especially: a hie.yaml file)? Nope, the implicit cradle have been working fine for some time now

Debug information

michaelpj commented 7 months ago

Looks like implicit-hie messing up, adding a hie.yaml with an empty cradle fixes it. So since we got rid of implicit-hie in the latest release I think this should be fixed now.

teto commented 7 months ago

thanks for having looked into it ! Would you mind sharing your hie.yaml ? I haven't written one in a long time so I am kinda rusty. I tried to fetch the latest release from HLS's flake but apparently it doesn't provide any packages, just the devShells ? Sad :'( I suppose it was just too hard to maintain.

michaelpj commented 7 months ago

The usual

cradle:
  cabal:

I suppose it was just too hard to maintain.

We have had no shortage of people who want to set up various sorts of nix stuff in the repository, but none who want to stick around and maintain it ;)

teto commented 7 months ago

Thank you very much that solved it !

We have had no shortage of people who want to set up various sorts of nix stuff in the repository, but none who want to stick around and maintain it ;)

I used to be one of those fools trying to provide nix packages for different versions of ghc but haskell is high maintainence, with libraries lagging a lot behind latest ghc. I totally get why those got removed no problem.