Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only when eval in Language Server: certain TemplateHaskell module not found #168

Open
archywillhe opened this issue Aug 16, 2023 · 2 comments

Comments

@archywillhe
Copy link

archywillhe commented Aug 16, 2023

So I'm using using some TemplateHaskell packages. Namely Data.Aeson.TypeScript.TH.

The code got compiled and all was good.

So it's working just great.

But if I'm debugging and try to eval in the Haskell Language Server I will get an error of module not found:

--- >>> runInterpreter $ runHint "HsToRedux_item" "2023-08-16_18-06-51"    
-- Left (WontCompile [GhcError {errMsg = "_mixed/HsToRedux_item/2023-08-16_18-06-51.hs:13:1: error:\n    Could not find module \8216Data.Aeson.TypeScript.TH\8217\n    Use -v (or `:set -v` in ghci) to see a list of the files searched for."},GhcError {errMsg = "_mixed/HsToRedux_item/2023-08-16_18-06-51.hs:14:1: error:\n    Could not find module \8216Data.Aeson.Types\8217\n    Use -v (or `:set -v` in ghci) to see a list of the files searched for."}])

(I did setImports ["Prelude", "Language.Haskell.TH", "GHC.Generics", "Data.Aeson", "Data.Aeson.TypeScript.TH","Data.Aeson.Types"] just fine with set [languageExtensions := [TemplateHaskell,ScopedTypeVariables]])

or can probably be a bug somewhere in the HLS?

@archywillhe
Copy link
Author

archywillhe commented Aug 16, 2023

any tips on debugging this or hacking around will be nice! Thanks!

@archywillhe archywillhe changed the title certain TemplateHaskell module not found when eval in Language Server only when eval in Language Server: certain TemplateHaskell module not found Aug 16, 2023
@gelisam
Copy link
Contributor

gelisam commented Aug 18, 2023

hint is not finding the package databases in which that library is installed. The README recommends using a ghc environment file in the present working directory, as I have had a good experience with that approach with both running a compiled executable, with ghci, and ghcid. However, I have not tried this approach with HLS, so it is possible that the second approach mentioned in the README, in which the ghc environment file or the package database is explicitly specified via unsafeRunInterpreterWithArgs, works better.

It is also possible that HLS is setting the GHC_PACKAGE_PATH environment variable.

Does that help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants