Haskell-language-server: ghc version mismatch with cabal cradle and alternative ghc in cabal.project

Created on 25 Aug 2020  路  7Comments  路  Source: haskell/haskell-language-server

  • In the hls codebase, using hls b6c1551, setting with-compiler: ghc-8.10.1 in the cabal.project and with ghc-8.8.4 as default ghc in $PATH
  • hls-wrapper picks up hls-8.10.1 correctly but then the cradle builds the project with ghc-8.8.4, ending with an error:
[client] run command: "haskell-language-server-wrapper --lsp"
[client] debug command: "haskell-language-server-wrapper --lsp"
[client] server cwd: undefined
Found "d:\dev\ws\haskell\hls\hie.yaml" for "d:\dev\ws\haskell\hls\a"
Module "d:\dev\ws\haskell\hls\a" is loaded by Cradle: Cradle {cradleRootDir = "d:\\dev\\ws\\haskell\\hls", cradleOptsProg = CradleAction: Cabal}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.3.0.0 x86_64 ghc-8.10.1
Current directory: d:\dev\ws\haskell\hls
Operating system: mingw32
Arguments: ["--lsp"]
Cradle directory: d:\dev\ws\haskell\hls
Cradle type: Cabal

Tool versions found on the $PATH
cabal:      3.2.0.0
stack:      2.3.3
ghc:        8.8.4


Consulting the cradle to get project GHC version...
Project GHC version: 8.10.1
haskell-language-server exe candidates: ["haskell-language-server-8.10.1.exe","haskell-language-server-8.10.exe","haskell-language-server.exe"]
Launching haskell-language-server exe at:D:\bin\haskell-language-server-8.10.1.exe
haskell-language-server version: 0.3.0.0 (GHC: 8.10.1) (PATH: D:\bin\haskell-language-server-8.10.1.exe)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide",PluginId "importLens",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "stylish-haskell"]
  in directory: d:\dev\ws\haskell\hls
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.02s
2020-08-25 21:26:21.3141183 [ThreadId 13] - Opened text document: file:///d%3A/dev/ws/haskell/hls/src/Ide/Plugin.hs
2020-08-25 21:26:21.3201245 [ThreadId 45] - Data.HashMap.Internal.(!): key not found
CallStack (from HasCallStack):
  error, called at .\\Data\\HashMap\\Internal.hs:753:16 in unordered-con_-0.2.12.0-a2bdce8125a14ad7620eee9f7260917d8fb6b506:Data.HashMap.Internal
  !, called at src\Development\IDE\Import\DependencyInformation.hs:107:40 in ghcide-0.2.0-1c40da733b46d980c61fcd5ffc511319a73a90cc:Development.IDE.Import.DependencyInformation
2020-08-25 21:26:21.3241254 [ThreadId 40] - Consulting the cradle for "D:\\dev\\ws\\haskell\\hls\\src\\Ide\\Plugin.hs"
Output from setting up the cradle Cradle {cradleRootDir = "D:\\dev\\ws\\haskell\\hls", cradleOptsProg = CradleAction: Cabal}
> Resolving dependencies...
> Build profile: -w ghc-8.8.4 -O1
> In order, the following will be built (use -v for more details):
>  - ghcide-0.2.0 (lib) (configuration changed)
>  - haskell-language-server-0.3.0.0 (lib) (configuration changed)
> Configuring library for ghcide-0.2.0..
> Preprocessing library for ghcide-0.2.0..
> Building library for ghcide-0.2.0..
> [28 of 47] Compiling Development.IDE.Core.RuleTypes ( src\Development\IDE\Core\RuleTypes.hs, D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\ghcide-0.2.0\build\Development\IDE\Core\RuleTypes.o )
...
> [47 of 47] Compiling Development.IDE.LSP.LanguageServer ( src\Development\IDE\LSP\LanguageServer.hs, D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\ghcide-0.2.0\build\Development\IDE\LSP\LanguageServer.o )
> Configuring library for haskell-language-server-0.3.0.0..
> Preprocessing library for haskell-language-server-0.3.0.0..

The error:

ghcide compiled by GHC 8.10 failed to load packages: <command line>: cannot satisfy -package-id Diff-0.4.0-b9ff4ae8fe1ffd1760eed395d751e7769f9fa0b6: 
    Diff-0.4.0-b9ff4ae8fe1ffd1760eed395d751e7769f9fa0b6 is unusable due to missing dependencies:
      base-4.13.0.0
    (use -v for more information). 
Please ensure that ghcide is compiled with the same GHC installation as the project.

It seems it is in the ghcide side. I thought the @bubba pr https://github.com/digital-asset/ghcide/pull/696 fixed that.

hie-bios blocked upstream bug

All 7 comments

It seems hie-bios-0.6.3 works fine and selects ghc-8.10.1:

PS D:\dev\ws\haskell\hls> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.4
PS D:\dev\ws\haskell\hls> cat .\cabal.project | grep "with-compiler"
with-compiler: ghc-8.10.1
PS D:\dev\ws\haskell\hls> hie-bios version
hie-bios version 0.6.3 compiled by GHC 8.8.4
PS D:\dev\ws\haskell\hls> hie-bios debug src
Root directory:        D:\dev\ws\haskell\hls
Component directory:   D:\dev\ws\haskell\hls
GHC options:           -fbuilding-cabal-package -O0 -outputdir D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -odir D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -hidir D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -stubdir D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -i -iD:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -isrc -iD:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\autogen -iD:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\global-autogen -ID:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\autogen -ID:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\global-autogen -ID:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -Iinclude -ID:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\include -optP-DAGPL -optP-include -optPD:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\autogen\cabal_macros.h -this-unit-id haskell-language-server-0.3.0.0-inplace -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db C:\sd\ghc-8.8.4\package.db -package-db D:\dev\ws\haskell\hls\dist-newstyle\packagedb\ghc-8.8.4 -package-db D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\package.conf.inplace -package-id Diff-0.4.0-b9ff4ae8fe1ffd1760eed395d751e7769f9fa0b6 -package-id Win32-2.6.1.0 -package-id aeson-1.5.2.0-3fe17a094e432e2dee10e316e4d73fe91c242179 -package-id base-4.13.0.0 -package-id binary-0.8.7.0 -package-id brittany-0.12.1.1-inplace -package-id bytestring-0.10.10.1 -package-id containers-0.6.2.1 -package-id data-default-0.7.1.1-ae69121e14977f5e532584ddf6fbac125b8b0427 -package-id deepseq-1.4.4.0 -package-id directory-1.3.6.0 -package-id extra-1.7.4-cc86c0598884c8be492184d5f47a20c6c4947df0 -package-id filepath-1.4.2.1 -package-id floskell-0.10.4-286f8612150da497e3ad591c91140bc6de3fc7c5 -package-id fourmolu-0.1.0.0-99bc11a30b02fe4a0f6af88841574e08da776b63 -package-id ghc-8.8.4 -package-id ghc-boot-th-8.8.4 -package-id ghcide-0.2.0-inplace -package-id gitrev-1.3.1-c62a04a160d967bd49c9cea5dd497a92bce72592 -package-id hashable-1.3.0.0-23f5ee60efaaffddf1ba167a3107a5bc01763239 -package-id haskell-lsp-0.22.0.0-2277925363e1572e4b1efbba2c0a40f537019b1f -package-id hie-bios-0.6.1-474151a247d0416d2604cba396f6553453a70a55 -package-id hslogger-1.3.1.0-b0f8fe000e803ec3fff9d7464e393a56404d5255 -package-id lens-4.19.2-e47ce26ae0ec44a576463dd71f2a27440c696b40 -package-id optparse-simp_-0.1.1.2-f34cbd1688a2d87f283dff1499dba4c6c372e4a4 -package-id ormolu-0.1.2.0-b1ab1ab645841b39aead9e3efa26a214a87ce1e8 -package-id process-1.6.9.0 -package-id regex-tdfa-1.3.1.0-d9ec551d3a15f856182c7722428f3a8c9f7639d1 -package-id retrie-0.1.1.1-8466c5f5c212245b1b89655169766a3e4fce9c06 -package-id safe-exceptio_-0.1.7.0-0148e161095cd4269c7075ffe3ebce9b1cb71926 -package-id shake-0.19.1-e5993b6e8781c8b2ba1e884919dd5867b871443a -package-id stylish-haske_-0.11.0.3-9c0fc821aa2a98400691c6ac88f1663844b1e994 -package-id temporary-1.3-6d75304f46a058f43faf93bfb87c3f096740985d -package-id text-1.2.4.0 -package-id time-1.9.3 -package-id transformers-0.5.6.2 -package-id unordered-con_-0.2.12.0-1192b25237766ca58e9b86d1bfeda28df38b262c -XHaskell2010 Ide.Logger Ide.Plugin Ide.Plugin.Config Ide.Plugin.Eval Ide.Plugin.Example Ide.Plugin.Example2 Ide.Plugin.Fourmolu Ide.Plugin.GhcIde Ide.Plugin.ImportLens Ide.Plugin.Ormolu Ide.Plugin.Pragmas Ide.Plugin.Retrie Ide.Plugin.Floskell Ide.Plugin.Formatter Ide.Plugin.StylishHaskell Ide.PluginUtils Ide.Types Ide.Version Ide.Plugin.Brittany Paths_haskell_language_server -Wall -Wredundant-constraints -Wno-name-shadowing -hide-all-packages -haddock
GHC library directory: CradleSuccess "D:\\bin\\stack\\x86_64-windows\\ghc-8.10.1\\lib"
GHC version:           CradleSuccess "8.10.1"
Config Location:       D:\dev\ws\haskell\hls\hie.yaml
Cradle:                Cradle {cradleRootDir = "D:\\dev\\ws\\haskell\\hls", cradleOptsProg = CradleAction: Cabal}
Dependencies:          haskell-language-server.cabal cabal.project cabal.project.local

@jneira I just tried this out, instinctively I first put the with-compiler: field in cabal.project.local and it worked ok, but if I put it in cabal.project I can recreate it 馃

@jneira If I put the with-compiler field at the top of cabal.project it works, but at the bottom it fails. Is there something funny going on with how cabal is parsing the project files?

@jneira If I put the with-compiler field at the top of cabal.project it works, but at the bottom it fails. Is there something funny going on with how cabal is parsing the project files?

mmm, maybe there was another factor around, i've just tried to move the field to the top and i am getting the same error

@jneira Yeah ignore those comments above, I hadn't put those same versions of ghc in my path correctly!

It seems hie-bios-0.6.3 works fine and selects ghc-8.10.1:

PS D:\dev\ws\haskell\hls> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.4
PS D:\dev\ws\haskell\hls> cat .\cabal.project | grep "with-compiler"
with-compiler: ghc-8.10.1
PS D:\dev\ws\haskell\hls> hie-bios version
hie-bios version 0.6.3 compiled by GHC 8.8.4
PS D:\dev\ws\haskell\hls> hie-bios debug src
Root directory:        D:\dev\ws\haskell\hls
Component directory:   D:\dev\ws\haskell\hls
GHC options:           -fbuilding-cabal-package -O0 -outputdir D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -odir D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -hidir D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -stubdir D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -i -iD:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -isrc -iD:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\autogen -iD:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\global-autogen -ID:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\autogen -ID:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\global-autogen -ID:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build -Iinclude -ID:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\include -optP-DAGPL -optP-include -optPD:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\build\autogen\cabal_macros.h -this-unit-id haskell-language-server-0.3.0.0-inplace -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db C:\sd\ghc-8.8.4\package.db -package-db D:\dev\ws\haskell\hls\dist-newstyle\packagedb\ghc-8.8.4 -package-db D:\dev\ws\haskell\hls\dist-newstyle\build\x86_64-windows\ghc-8.8.4\haskell-language-server-0.3.0.0\package.conf.inplace -package-id Diff-0.4.0-b9ff4ae8fe1ffd1760eed395d751e7769f9fa0b6 -package-id Win32-2.6.1.0 -package-id aeson-1.5.2.0-3fe17a094e432e2dee10e316e4d73fe91c242179 -package-id base-4.13.0.0 -package-id binary-0.8.7.0 -package-id brittany-0.12.1.1-inplace -package-id bytestring-0.10.10.1 -package-id containers-0.6.2.1 -package-id data-default-0.7.1.1-ae69121e14977f5e532584ddf6fbac125b8b0427 -package-id deepseq-1.4.4.0 -package-id directory-1.3.6.0 -package-id extra-1.7.4-cc86c0598884c8be492184d5f47a20c6c4947df0 -package-id filepath-1.4.2.1 -package-id floskell-0.10.4-286f8612150da497e3ad591c91140bc6de3fc7c5 -package-id fourmolu-0.1.0.0-99bc11a30b02fe4a0f6af88841574e08da776b63 -package-id ghc-8.8.4 -package-id ghc-boot-th-8.8.4 -package-id ghcide-0.2.0-inplace -package-id gitrev-1.3.1-c62a04a160d967bd49c9cea5dd497a92bce72592 -package-id hashable-1.3.0.0-23f5ee60efaaffddf1ba167a3107a5bc01763239 -package-id haskell-lsp-0.22.0.0-2277925363e1572e4b1efbba2c0a40f537019b1f -package-id hie-bios-0.6.1-474151a247d0416d2604cba396f6553453a70a55 -package-id hslogger-1.3.1.0-b0f8fe000e803ec3fff9d7464e393a56404d5255 -package-id lens-4.19.2-e47ce26ae0ec44a576463dd71f2a27440c696b40 -package-id optparse-simp_-0.1.1.2-f34cbd1688a2d87f283dff1499dba4c6c372e4a4 -package-id ormolu-0.1.2.0-b1ab1ab645841b39aead9e3efa26a214a87ce1e8 -package-id process-1.6.9.0 -package-id regex-tdfa-1.3.1.0-d9ec551d3a15f856182c7722428f3a8c9f7639d1 -package-id retrie-0.1.1.1-8466c5f5c212245b1b89655169766a3e4fce9c06 -package-id safe-exceptio_-0.1.7.0-0148e161095cd4269c7075ffe3ebce9b1cb71926 -package-id shake-0.19.1-e5993b6e8781c8b2ba1e884919dd5867b871443a -package-id stylish-haske_-0.11.0.3-9c0fc821aa2a98400691c6ac88f1663844b1e994 -package-id temporary-1.3-6d75304f46a058f43faf93bfb87c3f096740985d -package-id text-1.2.4.0 -package-id time-1.9.3 -package-id transformers-0.5.6.2 -package-id unordered-con_-0.2.12.0-1192b25237766ca58e9b86d1bfeda28df38b262c -XHaskell2010 Ide.Logger Ide.Plugin Ide.Plugin.Config Ide.Plugin.Eval Ide.Plugin.Example Ide.Plugin.Example2 Ide.Plugin.Fourmolu Ide.Plugin.GhcIde Ide.Plugin.ImportLens Ide.Plugin.Ormolu Ide.Plugin.Pragmas Ide.Plugin.Retrie Ide.Plugin.Floskell Ide.Plugin.Formatter Ide.Plugin.StylishHaskell Ide.PluginUtils Ide.Types Ide.Version Ide.Plugin.Brittany Paths_haskell_language_server -Wall -Wredundant-constraints -Wno-name-shadowing -hide-all-packages -haddock
GHC library directory: CradleSuccess "D:\\bin\\stack\\x86_64-windows\\ghc-8.10.1\\lib"
GHC version:           CradleSuccess "8.10.1"
Config Location:       D:\dev\ws\haskell\hls\hie.yaml
Cradle:                Cradle {cradleRootDir = "D:\\dev\\ws\\haskell\\hls", cradleOptsProg = CradleAction: Cabal}
Dependencies:          haskell-language-server.cabal cabal.project cabal.project.local

It looks like hie-bios is actually picking the wrong version in options, the paths have 8.8.4 in them, which seems to be coming from a result of the wrapper script

Yeah, i forgot about how hie-bios works internally, i filled an issue myself in hie-bios about: https://github.com/mpickering/hie-bios/issues/194

Was this page helpful?
0 / 5 - 0 ratings