Skip to content

Can't use test suites for GHC plugins, HLS erroneously claims that build-depends entry is missing #3297

@JakobBruenker

Description

@JakobBruenker
Contributor

Your environment

Ubuntu (under Windows 11 WSL)
ghc 9.4.2 via ghcup

Reproduction repo with minimal example:
https://github.com/JakobBruenker/a-cabal-error

Which LSP client (editor/plugin) do you use?
VS Code, but running haskell-language-server outside of it produces the same error

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

Have you configured HLS in any way (especially: a hie.yaml file)?
No (though an hie.yaml file generated via implicit-hie seemed to make no difference)

Steps to reproduce

Run haskell-language-server on the reproduction repo linked above

Expected behaviour

There should only be one error, Variable not in scope: thisShouldBeAnError :: IO ()

Actual behaviour

The expected error appears, but another error appears as well:

Unexpected usage error
Could not load module ‘APlugin’
It is a member of the hidden package ‘a-cabal-error-0.1.0.0’.
Perhaps you need to add ‘a-cabal-error’ to the build-depends in your .cabal file.
Use -v (or `:set -v` in ghci) to see a list of the files searched for.

This is rather strange, since the .cabal file does contain that dependency, and cabal test runs fine.

Activity

JakobBruenker

JakobBruenker commented on Oct 29, 2022

@JakobBruenker
ContributorAuthor

Workaround: Instead of (edit: or maybe in addition to) using build-depends, you can use ghc-options: -plugin-package=<package-name>. This seems to work.

changed the title [-]Can't run test suites for GHC plugins, HLS erroneously claims that build-depends entry is missing[/-] [+]Can't use test suites for GHC plugins, HLS erroneously claims that build-depends entry is missing[/+] on Oct 30, 2022
michaelpj

michaelpj commented on Nov 2, 2022

@michaelpj
Collaborator

Maybe this is also related to us setting up plugins wrong? Does your other PR help this?

JakobBruenker

JakobBruenker commented on Nov 2, 2022

@JakobBruenker
ContributorAuthor

@michaelpj good question, it might be vaguely related, but the changes I've made so far do not seem to help

fendor

fendor commented on May 6, 2025

@fendor
Collaborator

Issue can still be reproduced, but it only occurs if you use lazy component loading and open the module APlugin before PluginTest.

It works if you use "haskell.sessionLoading": "multipleComponents" like in a .vscode/settings.json:

{
    "haskell.sessionLoading": "multipleComponents"
}

and this hie.yaml uses eager component loading.

cradle:
  cabal:
    component: "all"

Could be both, a HLS session loading initilisation bug or GHC multi home unit bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: ghcidetype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @michaelpj@fendor@JakobBruenker

        Issue actions

          Can't use test suites for GHC plugins, HLS erroneously claims that build-depends entry is missing · Issue #3297 · haskell/haskell-language-server