GHC 9.4, stack and multiple components causes hidden package errors #3611
Labels
build tool: stack
component: ghcide
component: hie-bios
multi-component
Issues relating to multi-component support
type: bug
Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
After upgrading to GHC-9.4.5, we've been noticing a lot more of the
-package ... is hidden
errors in HLS with a stack multi-cradle.Initially I thought this was merely #366. But after further testing it's clear that this is caused by something else. #366 is caused by
stack repl
failing to pass the correct arguments when components aren't already built. But this error also happens when they have successfully built.I then compared the dynflags that
cabal
andstack
produce for the same project. I noticed thatcabal
passed-this-unit-id
whilestack
did not. Adding-this-unit-id <package-name>
to ghc-options for each package made the new problem go away.So, my theory is that because
stack repl
doesn't pass-this-unit-id
to GHC, something with GHC's new MHU breaks, causing only the dependencies of one package to be exposed in HLS's GHC API session.My impression is that this issue will occur when using HLS, with stack, GHC 9.4, and any session with multiple components loaded.
I've created a somewhat minimal reproducer below.
Your environment
Which OS do you use? NixOS
Which version of GHC do you use and how did you install it? GHC 9.4.5 using nix
How is your project built (alternative: link to the project)? stack
Which LSP client (editor/plugin) do you use? emacs+lsp-mode
Which version of HLS do you use and how did you install it? 1.10.0 and 2.0.0 (built with nix)
Have you configured HLS in any way (especially: a
hie.yaml
file)? yes, hie.yaml generated bygen-hie
Steps to reproduce
I've created a somewhat minimal reproducer: https://github.com/TeofilC/hls-repro-1
It features two packages that have different dependencies.
When opening both in a single HLS session with stack, HLS fails with a
-package is hidden
error.git clone https://github.com/TeofilC/hls-repro-1.git
cd hls-repro-1
nix develop
(if you use nix or get stack/hls some other way)stack build
haskell-language-server -d pack-a/src/Lib1.hs pack-b/src/Lib2.hs
If using nix make sure you have the following in your .stack/config:
Expected behaviour
HLS should be able to load these modules and can do if we use cabal instead.
Actual behaviour
It fails:
Debug information
The text was updated successfully, but these errors were encountered: