Haskell-language-server: Can't find interface-file declaration when loading a TemplateHaskell-enabled module

Created on 6 Jun 2020  Â·  17Comments  Â·  Source: haskell/haskell-language-server

Current master (2310e1039c90d9bccaffd688a0d1ec79a9360bf4) of HLS fails to load threadscope like this:

ghcide version: 0.1.0.0 (GHC: 8.8.3) (PATH: /Users/maoe/.local/bin/haskell-language-server-wrapper)
ghcide version: 0.1.0.0 (GHC: 8.8.3) (PATH: /Users/maoe/.local/bin/haskell-language-server-8.8.3)
(haskell-language-server)Ghcide setup tester in /Users/maoe/src/github.com/haskell/ThreadScope.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/6: Finding files to test in /Users/maoe/src/github.com/haskell/ThreadScope
Found 1 files

Step 2/6: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/6: Initializing the IDE

Step 4/6: Type checking the files
Consulting the cradle for "/Users/maoe/src/github.com/haskell/ThreadScope/GUI/MainWindow.hs"
> Resolving dependencies...
> Build profile: -w ghc-8.8.3 -O1
> In order, the following will be built (use -v for more details):
>  - threadscope-0.2.13 (first run)
> Configuring threadscope-0.2.13...
> Preprocessing executable 'threadscope' for threadscope-0.2.13..
Right (ComponentOptions {componentOptions = ["-fbuilding-cabal-package","-O0","-outputdir","/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/thr
eadscope/threadscope-tmp","-odir","/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/threadscope/threadscope-tmp","-hidir","/Users/maoe/src/githu
b.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/threadscope/threadscope-tmp","-stubdir","/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-o
sx/ghc-8.8.3/threadscope-0.2.13/build/threadscope/threadscope-tmp","-i","-i/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/threadscope/threadsc
ope-tmp","-i.","-i/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/threadscope/autogen","-i/Users/maoe/src/github.com/haskell/ThreadScope/dist-n
ewstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/global-autogen","-I/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/threadscope/auto
gen","-I/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/global-autogen","-I/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x
86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/threadscope/threadscope-tmp","-Iinclude","-I/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/includ
e","-optP-include","-optP/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/build/threadscope/autogen/cabal_macros.h","-hide-all-packages","-Wmissing-ho
me-modules","-no-user-package-db","-package-db","/Users/maoe/.cabal/store/ghc-8.8.3/package.db","-package-db","/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/packagedb/ghc-8.8.3","-package-db","
/Users/maoe/src/github.com/haskell/ThreadScope/dist-newstyle/build/x86_64-osx/ghc-8.8.3/threadscope-0.2.13/package.conf.inplace","-package-id","array-0.5.4.0","-package-id","base-4.13.0.0","-package-id","bina
ry-0.8.7.0","-package-id","bytestring-0.10.10.0","-package-id","cr-0.13.8.0-d632bd6d","-package-id","containers-0.6.2.1","-package-id","deepseq-1.4.4.0","-package-id","fl-mbd-0.0.12.0-05bcb782","-package-id",
"filepath-1.4.2.1","-package-id","ghc-vnts-0.13.0-50e09703","-package-id","glb-0.13.8.0-7685cbfa","-package-id","gtk-0.15.4-094c3f5d","-package-id","mtl-2.2.2","-package-id","png-0.13.8.0-266afd56","-package-
id","template-haskell-2.15.0.0","-package-id","tmprry-1.3-bd69c6d2","-package-id","text-1.2.4.0","-package-id","time-1.9.3","-package-id","unix-2.7.2.2","-XHaskell98","-XRecordWildCards","-XNamedFieldPuns","-
XBangPatterns","-XPatternGuards","./Main.hs","Events.HECs","Events.EventDuration","Events.EventTree","Events.ReadEvents","Events.SparkStats","Events.SparkTree","Events.TestEvents","GUI.App","GUI.Main","GUI.Ma
inWindow","GUI.EventsView","GUI.DataFiles","GUI.Dialogs","GUI.SaveAs","GUI.Timeline","GUI.Histogram","GUI.TraceView","GUI.BookmarkView","GUI.KeyView","GUI.StartupInfoView","GUI.SummaryView","GUI.Types","GUI.C
oncurrencyControl","GUI.ProgressView","GUI.ViewerColours","GUI.Timeline.Activity","GUI.Timeline.CairoDrawing","GUI.Timeline.HEC","GUI.Timeline.Motion","GUI.Timeline.Render","GUI.Timeline.Sparks","GUI.Timeline
.Ticks","GUI.Timeline.Types","GUI.Timeline.Render.Constants","GUI.GtkExtras","Graphics.UI.Gtk.ModelView.TreeView.Compat","Paths_threadscope","-Wall","-fwarn-tabs","-rtsopts","-fno-warn-type-defaults","-fno-wa
rn-name-shadowing","-fno-warn-unused-do-bind","-hide-all-packages","-j"], componentRoot = "/Users/maoe/src/github.com/haskell/ThreadScope", componentDependencies = ["threadscope.cabal","cabal.project","cabal.
project.local"]})
"Making new HscEnv[main]"
(([],Just HscEnvEq 3),fromList [("cabal.project",Just 2020-05-25 15:56:56.78656145 UTC),("cabal.project.local",Just 2020-06-06 00:35:10.524803549 UTC),("threadscope.cabal",Just 2020-06-04 14:43:44.096629579 U
TC)])
[INFO] finish: TypecheckTest (took 4.67s)
File:     /Users/maoe/src/github.com/haskell/ThreadScope/GUI/MainWindow.hs
Hidden:   no
Range:    144:10-144:19
Source:   typecheck
Severity: DsError
Message:
  /Users/maoe/src/github.com/haskell/ThreadScope/GUI/MainWindow.hs:144:11: error:
  • Can't find interface-file declaration for variable GUI.DataFiles.renderLogo
  Probable cause: bug in .hi-boot file, or inconsistent .hi file
File:     /Users/maoe/src/github.com/haskell/ThreadScope/GUI/MainWindow.hs
Hidden:   no
Range:    144:10-144:19
Source:   typecheck
Severity: DsError
Message:
 /Users/maoe/src/github.com/haskell/ThreadScope/GUI/MainWindow.hs:144:11: error:                                                                                                                      [33/1583]
  • Can't find interface-file declaration for variable GUI.DataFiles.renderLogo
  Probable cause: bug in .hi-boot file, or inconsistent .hi file
  Use -ddump-if-trace to get an idea of which file caused the error
  • In a stmt of a 'do' block:
  logo <- (GUI.DataFiles.renderLogo
  (GHC.IO.Unsafe.unsafePerformIO
  ((Data.ByteString.Unsafe.unsafePackAddressLen 5358)

... very long blob dump here ...

  In the expression:
  do let getWidget cast name = builderGetObject builder cast name
  mainWindow <- getWidget castToWindow "main_window"
  statusBar <- getWidget castToStatusbar "statusbar"
  sidebarBox <- getWidget castToWidget "sidebar"
  ....
  In an equation for ‘mainWindowNew’:
  mainWindowNew builder actions
  = do let getWidget cast name = ...
  mainWindow <- getWidget castToWindow "main_window"
  statusBar <- getWidget castToStatusbar "statusbar"

Steps to reproduce:

git clone [email protected]:haskell/ThreadScope.git
cd ThreadScope
gen-hie > hie.yaml
cp cabal.project.osx cabal.project # if you're on macOS
haskell-language-server-wrapper GUI/MainWindow.hs

FWIW current master of ghcide fails silently on the same module:

% ghcide GUI/MainWindow.hs
ghcide version: 0.2.0 (GHC: 8.8.3) (PATH: /Users/maoe/.local/bin/ghcide)
Ghcide setup tester in /Users/maoe/src/github.com/haskell/ThreadScope.
Report bugs at https://github.com/digital-asset/ghcide/issues

Step 1/4: Finding files to test in /Users/maoe/src/github.com/haskell/ThreadScope
Found 1 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
[INFO] Consulting the cradle for "/Users/maoe/src/github.com/haskell/ThreadScope/GUI/MainWindow.hs"
> Resolving dependencies...
> Build profile: -w ghc-8.8.3 -O1
> In order, the following will be built (use -v for more details):
>  - threadscope-0.2.13 (configuration changed)
> Configuring threadscope-0.2.13...
> Preprocessing executable 'threadscope' for threadscope-0.2.13..
[INFO] Using interface files cache dir: /Users/maoe/.cache/ghcide/main-b3d011f566f19fbfdd392a1581bf784ebd22508d
[INFO] Making new HscEnv[main]
Files that failed:
 * /Users/maoe/src/github.com/haskell/ThreadScope/GUI/MainWindow.hs

Completed (0 files worked, 1 file failed)
ghcide bug

All 17 comments

Hi, it is a shoot in the dark but maybe cleaning the cache of ghcide and hie-bios. where they save hie files, could help: they are in $XDG_CACHE_DIRECTORY, by default ~/.cache in linux and C:/Users/<user>/AppData/Localin windows

Thanks. I’ll ll try that later. I’m having the same issue in our private in-house repository too so there may be a real issue. I’ll try to make a smaller reproducer.

I made a tiny reproducer: https://github.com/maoe/hls-reproducer. This project builds fine with cabal but if you run haskell-language-server MyLib.hs:

% haskell-language-server MyLib.hs
ghcide version: 0.1.0.0 (GHC: 8.10.1) (PATH: /Users/maoe/.local/bin/haskell-language-server)
(haskell-language-server)Ghcide setup tester in /Users/maoe/src/github.com/maoe/hls-reproducer.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/6: Finding files to test in /Users/maoe/src/github.com/maoe/hls-reproducer
Found 1 files

Step 2/6: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/6: Initializing the IDE

Step 4/6: Type checking the files
Consulting the cradle for "/Users/maoe/src/github.com/maoe/hls-reproducer/MyLib.hs"
> Resolving dependencies...
> Build profile: -w ghc-8.10.1 -O1
> In order, the following will be built (use -v for more details):
>  - hls-reproducer-0.1.0.0 (lib) (configuration changed)
> Configuring library for hls-reproducer-0.1.0.0..
> Warning: The 'license-file' field refers to the file 'LICENSE' which does not
> exist.
> Preprocessing library for hls-reproducer-0.1.0.0..
Right (ComponentOptions {componentOptions = ["-fbuilding-cabal-package","-O0","-outputdir","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-odir","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-hidir","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-stubdir","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-i","-i/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-i.","-i/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/autogen","-i/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/global-autogen","-I/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/autogen","-I/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/global-autogen","-I/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-optP-include","-optP/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/autogen/cabal_macros.h","-this-unit-id","hls-reproducer-0.1.0.0-inplace","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/Users/maoe/.cabal/store/ghc-8.10.1/package.db","-package-db","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/packagedb/ghc-8.10.1","-package-db","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/package.conf.inplace","-package-id","base-4.14.0.0","-package-id","template-haskell-2.16.0.0","-XHaskell2010","MyLib","MyLib.TH","-hide-all-packages","-j"], componentRoot = "/Users/maoe/src/github.com/maoe/hls-reproducer", componentDependencies = ["hls-reproducer.cabal","cabal.project","cabal.project.local"]})
"Making new HscEnv[hls-reproducer-0.1.0.0-inplace]"
(([],Just HscEnvEq 3),fromList [("cabal.project",Nothing),("cabal.project.local",Nothing),("hls-reproducer.cabal",Just 2020-06-12 22:52:11.923320712 UTC)])
[INFO] finish: TypecheckTest (took 3.54s)
File:     /Users/maoe/src/github.com/maoe/hls-reproducer/MyLib.hs
Hidden:   no
Range:    5:0-5:8
Source:   typecheck
Severity: DsError
Message:
  /Users/maoe/src/github.com/maoe/hls-reproducer/MyLib.hs:5:1: error:
  • Can't find interface-file declaration for variable MyLib.TH.myId
  Probable cause: bug in .hi-boot file, or inconsistent .hi file
  Use -ddump-if-trace to get an idea of which file caused the error
  • In the expression: MyLib.TH.myId
  In an equation for ‘x’: x = MyLib.TH.myId

And if you replace myId with id in the definition of template, hls works fine.

Thanks for the small reproducer, i hope it will help to identify the cause

Currently available workaround for this issue is to define myId in a separate module. See https://github.com/maoe/hls-reproducer/commit/c4add31790bb7b8e80f7108e9d5ab34804c5e753

And current master (4e7b2fcdbb66b7e1579ffb3bdf1456ea96529787) of ghcide again silently fails:

% ghcide MyLib.hs
ghcide version: 0.2.0 (GHC: 8.10.1) (PATH: /Users/maoe/.local/bin/ghcide)
Ghcide setup tester in /Users/maoe/src/github.com/maoe/hls-reproducer.
Report bugs at https://github.com/digital-asset/ghcide/issues

Step 1/4: Finding files to test in /Users/maoe/src/github.com/maoe/hls-reproducer
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE
[DEBUG] Warning: Client does not support watched files. Falling back to OS polling

Step 4/4: Type checking the files
[DEBUG] Set files of interest to: [NormalizedFilePath "/Users/maoe/src/github.com/maoe/hls-reproducer/MyLib.hs"]
[DEBUG] Restarting build session (aborting the previous one took 0.00s)
[INFO] Consulting the cradle for "/Users/maoe/src/github.com/maoe/hls-reproducer/MyLib.hs"
> Resolving dependencies...
> Build profile: -w ghc-8.10.1 -O1
> In order, the following will be built (use -v for more details):
>  - hls-reproducer-0.1.0.0 (lib) (configuration changed)
> Configuring library for hls-reproducer-0.1.0.0..
> Warning: The 'license-file' field refers to the file 'LICENSE' which does not
> exist.
> Preprocessing library for hls-reproducer-0.1.0.0..
[DEBUG] Session loading result: Right (ComponentOptions {componentOptions = ["-fbuilding-cabal-package","-O0","-outputdir","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-odir","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-hidir","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-stubdir","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-i","-i/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-i.","-i/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/autogen","-i/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/global-autogen","-I/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/autogen","-I/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/global-autogen","-I/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build","-optP-include","-optP/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/build/autogen/cabal_macros.h","-this-unit-id","hls-reproducer-0.1.0.0-inplace","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/Users/maoe/.cabal/store/ghc-8.10.1/package.db","-package-db","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/packagedb/ghc-8.10.1","-package-db","/Users/maoe/src/github.com/maoe/hls-reproducer/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hls-reproducer-0.1.0.0/package.conf.inplace","-package-id","base-4.14.0.0","-package-id","template-haskell-2.16.0.0","-XHaskell2010","MyLib","MyLib.TH","MyLib.Id","-hide-all-packages","-j"], componentRoot = "/Users/maoe/src/github.com/maoe/hls-reproducer", componentDependencies = ["hls-reproducer.cabal","cabal.project","cabal.project.local"]})
[INFO] Using interface files cache dir: /Users/maoe/.cache/ghcide/hls-reproducer-0.1.0.0-inplace-fcf21ae1d00a0b7d32b2fdbad8d30b79ecc88ba3
[INFO] Making new HscEnv[hls-reproducer-0.1.0.0-inplace]
[DEBUG] New Component Cache HscEnvEq: (([],Just HscEnvEq 1),fromList [("/Users/maoe/src/github.com/maoe/hls-reproducer/hie.yaml",Just 2020-06-12 22:48:18.092842954 UTC),("cabal.project",Nothing),("cabal.project.local",Nothing),("hls-reproducer.cabal",Just 2020-06-12 23:11:42.407055971 UTC)])
[DEBUG] Finishing build session(exception: AsyncCancelled)
[DEBUG] Restarting build session (aborting the previous one took 0.00s)
Files that failed:
 * /Users/maoe/src/github.com/maoe/hls-reproducer/MyLib.hs

Completed (0 files worked, 1 file failed)

Loading the hls-reproducer example in VSCode with ghcide HEAD works fine for me. The command line is a diagnostic tool, but not always equivalent to loading in an IDE.

Trying to build threadscope with Nix gets stuck in:

pepe@Arrow:~/scratch/threadscope-0.2.13$ nix-shell
these derivations will be built:
  /nix/store/9g0ksyqp8a1fa1jy96s3vaqlb8d14chk-cairo-0.13.8.0.drv
  /nix/store/q49yy5f3g6viyrn909174fy9w1fvlfym-glib-0.13.8.0.drv
  /nix/store/0ni8bg24wx5vfq9qijm144szqsx1bib3-pango-0.13.8.0.drv
  /nix/store/4xka8q9fc754iacgqqd0zlf8h9a4p6ls-gio-0.13.8.0.drv
  /nix/store/m25nkv6jj1gil171sjjjhbz4vgjp4r21-gtk-0.15.4.drv
  /nix/store/n9nv5wv4j5nd22f8dswm1gidq85w3950-ghc-8.10.1-with-packages.drv
building '/nix/store/9g0ksyqp8a1fa1jy96s3vaqlb8d14chk-cairo-0.13.8.0.drv'...
setupCompilerEnvironmentPhase
Build with /nix/store/si82shf1fvp87zkv0dx6bsr0hw4h0v0q-ghc-8.10.1.
unpacking sources
unpacking source archive /nix/store/lnm8xhdl34k3pvd5m2vhd0wkk8lifqll-cairo-0.13.8.0.tar.gz
source root is cairo-0.13.8.0
setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file cairo-0.13.8.0/Setup.hs
patching sources
Run jailbreak-cabal to lift version restrictions on build inputs.
compileBuildDriverPhase
setupCompileFlags: -package-db=/build/setup-package.conf.d -j4 -threaded
[1 of 1] Compiling Main             ( Setup.hs, /build/Main.o )

Setup.hs:5:1: error:
    Ambiguous module name ‘Gtk2HsSetup’:
      it was found in multiple packages:
      gtk2hs-buildtools-0.13.8.0 gtk2hs-buildtools-0.13.8.0
  |
5 | import Gtk2HsSetup ( gtk2hsUserHooks )
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

builder for '/nix/store/9g0ksyqp8a1fa1jy96s3vaqlb8d14chk-cairo-0.13.8.0.drv' failed with exit code 1
cannot build derivation '/nix/store/n9nv5wv4j5nd22f8dswm1gidq85w3950-ghc-8.10.1-with-packages.drv': 1 dependencies couldn't be built
error: build of '/nix/store/n9nv5wv4j5nd22f8dswm1gidq85w3950-ghc-8.10.1-with-packages.drv' failed

@maoe can you load the module MyLib in your editor (with hover and other lsp features), like @pepeiborra? please, use the just released version or master

@jneira I just tried haskell-language-server 0.2 (7ad18cfa2d358e9def610dff1c113c87eb0eb19c) and a fairly recent ghcide (035019d5f5931af4260bd54fab1c717522aeb902) with VSCode 1.46.1 on macOS. I used GHC 8.10.1 except for HIE.

"languageServerHaskell.hieVariant": "haskell-language-server"

This reproduces the error.

Screen Shot 2020-07-06 at 22 05 58

"languageServerHaskell.hieVariant": "ghcide"

This also reproduces the error.

Screen Shot 2020-07-06 at 22 07 48

The ghcide extension instead of the Haskell Language Server extension

I couldn't get the ghcide extension working. It prints a lot of errors as follows:

Screen Shot 2020-07-06 at 22 10 04

"languageServerHaskell.hieVariant": "haskell-language-server"

It works as expected. Because HIE doesn't support 8.10 I used 8.8.3 for this demonstration.

Screen Shot 2020-07-06 at 22 17 25

The obvious question would be if hls works with GHC 8.8.3. The answer is no. It fails in the same way as GHC 8.10.1.

I confirmed that ghcide from wz1000/ghcide on the hls-3 branch fixes this issue. For those who are eager to try, add the following snippet to cabal.project when building hls:

source-repository-package
  type: git
  location: https://github.com/wz1000/ghcide.git
  tag: 493e960a7aa73f64ce3b631c69f6a60aa3a5b5f0

I still see this issue in our in-house codebase even with the patched ghcide. I'll try to make a reproducer.

I can reproduce this issue with https://github.com/jbransen/hls-bug using haskell-language-server-8.8.4 (75c4ebca614bdf45455f3231f388a218b65f2af6). stack build succeeds, haskell-language-server-8.8 A.hs fails with:

File:     .../hls-bug/A.hs
Hidden:   no
Range:    14:11-14:13
Source:   typecheck
Severity: DsError
Message:
  • Can't find interface-file declaration for data constructor Y
  Probable cause: bug in .hi-boot file, or inconsistent .hi file
  Use -ddump-if-trace to get an idea of which file caused the error
  • In the first argument of ‘C’, namely ‘'Y’
  In the instance declaration for ‘C 'Y’
Files that failed:
 * .../hls-bug/A.hs
[INFO] finish: User TypeCheck (took 1.84s)

FWIW I tried some intermediate commit of https://github.com/haskell/ghcide/pull/836 with hls and it fixed the issue in our codebase. I had to disable a few plugins to build hls though. So I think #463 is going to fix this issue.

I can confirm that #530 seems to have solved this! Latest master now works fine for my bigger projects.

@jbransen great! thanks for confirming it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mouse07410 picture mouse07410  Â·  4Comments

Ailrun picture Ailrun  Â·  3Comments

danbroooks picture danbroooks  Â·  3Comments

georgefst picture georgefst  Â·  3Comments

ProofOfKeags picture ProofOfKeags  Â·  4Comments