Skip to content

Dynlinked binaries use wrong ghc-paths inside TH #2872

@pepeiborra

Description

@pepeiborra

Your environment

Which OS do you use:
MacOS

Which LSP client (editor/plugin) do you use:
VSCode

Describe your project (alternative: link to the project):
HLS 1.7 distro binaries gives an unexpected diagnostic when type checking TH code that uses GHC.Paths.libdir

Steps to reproduce

Load the ghcide codebase and open ghcide/session-loader/Development/IDE/Session/VersionCheck.hs. The referenced function makeGhcVersionChecker comes from the ghc-check package and is throwing at:

  libdir <- GHC.Paths.getLibdir
  libdirExists <- doesDirectoryExist libdir
  unless libdirExists
    $ error
    $ "I could not find a GHC installation at " <> libdir
      <> ". Please do a clean rebuild and/or reinstall GHC."
  ...

Expected behaviour

No diagnostics are shown, the code compiles

Actual behaviour

• Exception when trying to run compile-time code:
    I could not find a GHC installation at /Users/builder/builds/oBRYs8oB/0/haskell/haskell-language-server/toolchain/.ghcup/ghc/8.10.7/lib/ghc-8.10.7. Please do a clean rebuild and/or reinstall GHC.
CallStack (from HasCallStack):
  error, called at src/GHC/Check.hs:188:7 in ghc-chck-0.5.0.6-2fb35c95:GHC.Check
  Code: makeGhcVersionChecker
          (fromMaybe GHC.Paths.libdir <$> lookupEnv "NIX_GHC_LIBDIR")
• In the Template Haskell splice
    $$(makeGhcVersionChecker
         (fromMaybe GHC.Paths.libdir <$> lookupEnv "NIX_GHC_LIBDIR"))
  In the expression:
    $$(makeGhcVersionChecker
         (fromMaybe GHC.Paths.libdir <$> lookupEnv "NIX_GHC_LIBDIR"))
  In an equation for ‘ghcVersionChecker’:
      ghcVersionChecker
        = $$(makeGhcVersionChecker
               (fromMaybe GHC.Paths.libdir <$> lookupEnv "NIX_GHC_LIBDIR"))

Include debug information

  • The problem does not arise when using locally built HLS 1.7 binaries.
  • My ghc lives in /home/pepeiborra/.ghcup/ghc/8.10.7. The diagnostic is looking for it in /Users/builder/builds/oBRYs8oB/0/haskell/haskell-language-server/toolchain/.ghcup/ghc/8.10.7/lib/ghc-8.10.7 which looks like a CI builder location.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CIContinuous integrationcomponent: ghcidepriority: highHigh priority itemtype: 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

    Issue actions