haskell/haskell-language-server

Error when using GHC type-checker plugins.

Opened this issue · 1 comments

chfin commented

When using GHC type-checker plugins (ghc-typelits-knownnat and ghc-typelits-natnormalize), HLS reports errors. In the editor, the error

Unexpected usage error
The name Plugin is not in the type environment: are you sure it exists?

is shown. When running hls on the command line, the error

Program error: Failed to load interface for ‘GHC.Driver.Plugins’.
  no unit id matching ‘ghc-9.10.3-415c’ was found

is reported for the file using the plugins.

Your environment

Which OS do you use?
Arch Linux

Which version of GHC do you use and how did you install it?
9.10.3 with stack

How is your project built (alternative: link to the project)?
stack. Link to minimal project: https://github.com/chfin/ghc-plugins-hls-bug

Which LSP client (editor/plugin) do you use?
Emacs with lsp-mode, error also appears when using HLS on command line

Which version of HLS do you use and how did you install it?
2.12.0.0 compiled for ghc-9.10.3 with ghcup

Have you configured HLS in any way (especially: a hie.yaml file)?
no

Steps to reproduce

Expected behaviour

HLS should build the project without issues and show no error in the file.

Actual behaviour

When opening src/Lib.hs, the editor shows an error message at the top of the file:

Unexpected usage error
The name Plugin is not in the type environment: are you sure it exists?

HLS reports the following error on src/Lib.hs:

2025-10-20T11:32:38.714246Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File:     <unknown>
Hidden:   no
Range:    1:1-2:1
Source:   pragmas
Severity: DiagnosticSeverity_Error
Code:     <none>
Message:
  Program error: Failed to load interface for ‘GHC.Driver.Plugins’.
  no unit id matching ‘ghc-9.10.3-415c’ was found

Debug information

haskell-language-server-wrapper --probe-tools
haskell-language-server version: 2.12.0.0 (GHC: 9.10.3) (PATH: /home/chfin/.ghcup/bin/haskell-language-server-wrapper-2.12.0.0)
Tool versions found on the $PATH
cabal:          3.16.0.0
stack:          3.7.1
ghc:            9.10.3

Tool versions in your project
2025-10-20T11:37:17.537410Z | Debug | stack --stack-yaml /home/chfin/dateien/dev/haskell/playgrounds/ghc-plugins-lsp-test/stack.yaml setup --silent
2025-10-20T11:37:17.879521Z | Debug | stack --stack-yaml /home/chfin/dateien/dev/haskell/playgrounds/ghc-plugins-lsp-test/stack.yaml exec ghc -- --numeric-version
ghc:            9.10.3
chfin commented

Looks like a somewhat similar error is described in #3297, not sure if that's related.