Description
I am troubleshooting haskell-language-server doing something wrong on the cabal repository. If I do:
$ haskell-language-server-wrapper cabal-install/tests/IntegrationTests2.hs
...
File: /home/andrea/code/cabal/cabal-install/tests/IntegrationTests2.hs
Hidden: no
Range: 77:8-77:19
Source: not found
Severity: DsError
Message:
Could not load module ‘Data.Tagged’
It is a member of the hidden package ‘tagged-0.8.7’.
Perhaps you need to add ‘tagged’ to the build-depends in your .cabal file.
which is wrong because IntegrationTests2
is part of the test-suite integration-tests2 which has indeed tagged
among its build-depens.
test-suite integration-tests2
import: warnings, base-dep, cabal-dep, cabal-syntax-dep, cabal-install-solver-dep
ghc-options: -rtsopts -threaded
type: exitcode-stdio-1.0
main-is: IntegrationTests2.hs
hs-source-dirs: tests
default-language: Haskell2010
build-depends:
bytestring,
cabal-install,
containers,
directory,
filepath,
tasty >= 1.2.3 && <1.5,
tasty-hunit >= 0.10,
tagged
to confirm I can do
cabal repl cabal-install/tests/IntegrationTests2.hs
which works ok.
I suspect that this happens because multiple components hs-source-dirs: tests
and indeed adding --debug
to hls shows
2023-05-25T03:26:53.728418Z | Debug | executing command: cabal --builddir=/home/andrea/.cache/hie-bios/dist-cabal-2d99de0514754dc7a0fdd74187917280 v2-repl --with-compiler /home/andrea/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/andrea/.cache/hie-bios/ghc-pkg-5fcb2ba7874e41991c2aef3124b07071 cabal-install:test:unit-tests
which is indeed the wrong component.
I checked directly with hie-bios (version 0.12.0) and it gets the component right
$ hie-bios flags cabal-install/tests/IntegrationTests2.hs
...
[Debug] executing command: cabal --builddir=/home/andrea/.cache/hie-bios/dist-cabal-2d99de0514754dc7a0fdd74187917280 v2-repl --with-compiler /home/andrea/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/andrea/.cache/hie-bios/ghc-pkg-5fcb2ba7874e41991c2aef3124b07071 cabal-install/tests/IntegrationTests2.hs
[Debug] Build profile: -w ghc-9.4.5 -O1
[Debug] In order, the following will be built (use -v for more details):
[Debug] - cabal-install-3.11.0.0 (test:integration-tests2) (first run)
[Debug] Configuring test suite 'integration-tests2' for cabal-install-3.11.0.0..
...
Your environment
Which OS do you use? Linux
Which version of GHC do you use and how did you install it? 9.4.5, via ghcup
How is your project built (alternative: link to the project)? https://github.com/haskell/cabal/
Which LSP client (editor/plugin) do you use? N/A
Which version of HLS do you use and how did you install it? 2.0.0.0 from ghcup
Have you configured HLS in any way (especially: a hie.yaml
file)? No