haskell / haskell/haskell-language-server
"lookupGREInfo: lookup failed" error involving TemplateHaskell and re-exports
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 12
Description
### Your environment
Which OS do you use? Linux Mint
Which version of GHC do you use and how did you install it? 9.14.1 from ghcup
How is your project built? https://github.com/adamgundry/hls-bug
Which LSP client (editor/plugin) do you use? VSCode+vscode-haskell
Which version of HLS do you use and how did you install it? 2.14.0.0 from ghcup
Have you configured HLS in any way? No
```
haskell-language-server version: 2.14.0.0 (GHC: 9.10.3) (PATH: /home/adam/.ghcup/hls/2.14.0.0/lib/haskell-language-server-2.14.0.0/bin/haskell-language-server-wrapper)
Tool versions found on the $PATH
cabal: 3.16.1.0
stack: 3.3.1
ghc: 9.14.1
```
### Steps to reproduce
Check out the example at https://github.com/adamgundry/hls-bug (minimized from a big private project). This is a multi-component project with two components `comp-a` and `comp-b`, where both use `TemplateHaskell`. The module A contains a definition of `foo` (generated from a TH splice), which module A2 re-exports. Module B then imports it via A2, and references it via another TH splice.
Opening `B.hs`, `A2.hs` and `A.hs` in VSCode then making changes (e.g. changing `import A2` to `import A` and back, or modifying the exports of `A2`) occasionally results in the following error at the top of `B.hs`:
```
lookupGREInfo
lookup failed: foo
Call stack:
CallStack (from HasCallStack):
pprPanic, called at compiler/GHC/Rename/Env.hs:2030:15 in ghc-9.14.1-3f81:GHC.Rename.Env
Please report this bug to the compiler authors.
```
I have occasionally seen other issues, such as failures to load interface files, or an incorrect claim that `A2` does not export `foo`. The issues seem to be somewhat nondeterministic, and only seem to happen when making edits to the project. In particular, running `haskell-language-server-wrapper-2.14.0.0 typecheck` succeeds (see log below).
This seems somewhat similar to https://gitlab.haskell.org/ghc/ghc/-/work_items/27227 / https://github.com/haskell/cabal/issues/7684.
### Debug information
```
$ haskell-language-server-wrapper-2.14.0.0 typecheck
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper-2.14.0.0) Version 2.14.0.0 x86_64 ghc-9.10.3
Current directory: /home/adam/Documents/Well-Typed/Code/hls-bug
Operating system: linux
Arguments: ["typecheck","--cwd","/home/adam/Documents/Well-Typed/Code/hls-bug"]
Cradle directory: /home/adam/Documents/Well-Typed/Code/hls-bug
Cradle type: Cabal
Tool versions found on the $PATH
cabal: 3.16.1.0
stack: 3.3.1
ghc: 9.14.1
Consulting the cradle to get project GHC version...
2026-08-26T13:14:05.352202Z | Debug | cabal --numeric-version
2026-08-26T13:14:05.381468Z | Debug | cabal --builddir=/home/adam/.cache/hie-bios/dist-hls-bug-9e0fe59a9b659bf2c06b27ac4ecca845 path --output-format=json
2026-08-26T13:14:05.409047Z | Debug | /home/adam/.ghcup/bin/ghc --numeric-version
Project GHC version: 9.14.1
haskell-language-server exe candidates: ["haskell-language-server-9.14.1","haskell-language-server"]
Launching haskell-language-server exe at:/home/adam/.ghcup/bin/haskell-language-server-9.14.1
2026-08-26T13:14:05.440917Z | Debug | cabal --builddir=/home/adam/.cache/hie-bios/dist-hls-bug-9e0fe59a9b659bf2c06b27ac4ecca845 path --output-format=json
2026-08-26T13:14:05.543492Z | Debug | /home/adam/.ghcup/bin/ghc -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2026-08-26T13:14:05.573663Z | Debug | cabal --builddir=/home/adam/.cache/hie-bios/dist-hls-bug-9e0fe59a9b659bf2c06b27ac4ecca845 path --output-format=json
2026-08-26T13:14:05.603037Z | Debug | /home/adam/.ghcup/bin/ghc --print-libdir
2026-08-26T13:14:06.816334Z | Info | haskell-language-server version: 2.14.0.0 (GHC: 9.14.1) (PATH: /home/adam/.ghcup/hls/2.14.0.0/lib/haskell-language-server-2.14.0.0/bin/haskell-language-server-9.14.1)
2026-08-26T13:14:06.817247Z | Info | Directory: /home/adam/Documents/Well-Typed/Code/hls-bug
2026-08-26T13:14:06.817538Z | Info | Logging heap statistics every 60.00s
ghcide setup tester in /home/adam/Documents/Well-Typed/Code/hls-bug.
Report bugs at https://github.com/haskell/haskell-language-server/issues
Step 1/4: Finding files to test in /home/adam/Documents/Well-Typed/Code/hls-bug
2026-08-26T13:14:06.823914Z | Info | Using git to list file, relying on .gitignore
Found 3 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
2026-08-26T13:14:06.830831Z | Info | Cradle path: src-b/B.hs
2026-08-26T13:14:06.831971Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for src-b/B.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.
2026-08-26T13:14:06.835849Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2026-08-26T13:14:06.895566Z | Info | Load cabal cradle using single file
2026-08-26T13:14:06.896878Z | Info | cabal --builddir=/home/adam/.cache/hie-bios/dist-hls-bug-9e0fe59a9b659bf2c06b27ac4ecca845 v2-repl --keep-temp-files --with-repl /home/adam/.cache/hie-bios/repl-wrapper-fae20739a232ed1b9dcdf40eca9cf71e /home/adam/Documents/Well-Typed/Code/hls-bug/src-b/B.hs
Environment Variables
HIE_BIOS_OUTPUT: /tmp/HIE_BIOS_OUTPUT2847179-0
2026-08-26T13:14:11.431094Z | Info | Interface files cache directory: /home/adam/.cache/ghcide/hls-bug-0.1.0.0-inplace-a1f816539abe5d7f73bac38abe44a3a2012c2d64
2026-08-26T13:14:11.436007Z | Info | Making new HscEnv. In-place unit ids: [hls-bug-0.1.0.0-inplace]
2026-08-26T13:14:11.507308Z | Info | New loaded files: [/home/adam/Documents/Well-Typed/Code/hls-bug/src-b/B.hs]
2026-08-26T13:14:11.508557Z | Info | Cradle path: src-a/A.hs
2026-08-26T13:14:11.508650Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for src-a/A.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.
2026-08-26T13:14:11.509928Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2026-08-26T13:14:11.610015Z | Info | Load cabal cradle using single file
2026-08-26T13:14:11.615635Z | Info | cabal --builddir=/home/adam/.cache/hie-bios/dist-hls-bug-9e0fe59a9b659bf2c06b27ac4ecca845 v2-repl --keep-temp-files --with-repl /home/adam/.cache/hie-bios/repl-wrapper-fae20739a232ed1b9dcdf40eca9cf71e /home/adam/Documents/Well-Typed/Code/hls-bug/src-a/A.hs
Environment Variables
HIE_BIOS_OUTPUT: /tmp/HIE_BIOS_OUTPUT2847179-1
2026-08-26T13:14:13.592427Z | Info | Interface files cache directory: /home/adam/.cache/ghcide/hls-bug-0.1.0.0-inplace-comp-a-1bae43b96139f751f1ec3f56b6350bf9fbd0ddb9
2026-08-26T13:14:13.592531Z | Info | Interface files cache directory: /home/adam/.cache/ghcide/hls-bug-0.1.0.0-inplace-1bae43b96139f751f1ec3f56b6350bf9fbd0ddb9
2026-08-26T13:14:13.594463Z | Info | Making new HscEnv. In-place unit ids: [ hls-bug-0.1.0.0-inplace
, hls-bug-0.1.0.0-inplace-comp-a ]
2026-08-26T13:14:13.742935Z | Info | New loaded files: [ /home/adam/Documents/Well-Typed/Code/hls-bug/src-a/A2.hs
, /home/adam/Documents/Well-Typed/Code/hls-bug/src-a/A.hs ]
Completed (3 files worked, 0 files failed)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue in the linked minimal project using src-a/A.hs, src-a/A2.hs, and src-b/B.hs, comparing editor edits with the successful haskell-language-server-wrapper typecheck command. Start by examining the lookupGREInfo failure reported from GHC/Rename/Env.hs and the TemplateHaskell/re-export interaction. Done means the edits no longer produce the error, incorrect export reports, or interface-loading failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100