jonascarpay / template-haskell

batteries-included nix-based haskell project template
BSD 3-Clause "New" or "Revised" License
61 stars 10 forks source link

getting ghcide error #12

Closed FrankC01 closed 3 years ago

FrankC01 commented 3 years ago

I followed these steps:

git clone https://github.com/jonascarpay/template-haskell first-app
cd first-app
./wizard.sh
nix-shell
cabal new-build 
code .

And in code I am getting:

This is unsupported, ghcide must be compiled with the same GHC version as the project.
jonascarpay commented 3 years ago

What happens when you run haskell-language-server in the shell? If that runs without any problems, the issue has to be that your VS Code is not picking the right executable. In particular, it seems it's using some ghcide, rather than the haskell-language-server in your PATH..

FrankC01 commented 3 years ago
[nix-shell:~/haskell-projects/first-app]$ haskell-language-server
haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /nix/store/j8xivmf4j6xmsvq32g86029sh1m2adhj-haskell-language-server-exe-haskell-language-server-1.0.0.0/bin/haskell-language-server)
ghcide setup tester in /Users/frankcastellucci/haskell-projects/first-app.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /Users/frankcastellucci/haskell-projects/first-app
Found 4 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  (/Users/frankcastellucci/haskell-projects/first-app/hie.yaml)

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-06-30 10:33:49.071287 [ThreadId 82] INFO hls:  Consulting the cradle for "app/Main.hs"
2021-06-30 10:33:49.071273 [ThreadId 77] INFO hls:  File:
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError
Message:
  Internal error, getIdeGlobalExtras, no entry for IdeConfigurationVar
  CallStack (from HasCallStack):
  errorIO, called at src/Development/IDE/Core/Shake.hs:284:20 in
  ghcide-1.0.0.0-DHz8NdUddL1333UtS49TS5:Development.IDE.Core.Shake
Output from setting up the cradle Cradle {cradleRootDir = "/Users/frankcastellucci/haskell-projects/first-app", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.10.4 -O1
> In order, the following will be built (use -v for more details):
>  - first-app-0 (lib) (first run)
>  - first-app-0 (exe:first-app-exe) (first run)
> Preprocessing library for first-app-0..
> Building library for first-app-0..
> [1 of 1] Compiling Lib
> Configuring executable 'first-app-exe' for first-app-0..
> Warning: The package has an extraneous version range for a dependency on an
> internal library: first-app >=0 && ==0, first-app >=0 && ==0, first-app >=0 &&
> ==0. This version range includes the current package but isn't needed as the
> current package's library will always be used.
> Preprocessing executable 'first-app-exe' for first-app-0..
2021-06-30 10:33:51.247533 [ThreadId 82] INFO hls:  Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-902a2837d9476980ea18ebedbf1ef540dfb19925
2021-06-30 10:33:51.247879 [ThreadId 82] INFO hls:  Making new HscEnv[main]
2021-06-30 10:33:51.258159 [ThreadId 178] INFO hls: Consulting the cradle for "bench/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/frankcastellucci/haskell-projects/first-app", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.10.4 -O1
> In order, the following will be built (use -v for more details):
>  - first-app-0 (bench:first-app-bench) (first run)
> Configuring benchmark 'first-app-bench' for first-app-0..
2021-06-30 10:33:51.349699 [ThreadId 241] INFO hls: File:     /Users/frankcastellucci/haskell-projects/first-app/app/Main.hs
Hidden:   no
Range:    1:1-1:11
Source:   typecheck
Severity: DsWarning
Message:
  The import of ‘Lib’ is redundant
  except perhaps to import instances from ‘Lib’
  To import instances alone, use: import Lib()
> Warning: The package has an extraneous version range for a dependency on an
> internal library: first-app >=0 && ==0, first-app >=0 && ==0, first-app >=0 &&
> ==0. This version range includes the current package but isn't needed as the
> current package's library will always be used.
> Preprocessing benchmark 'first-app-bench' for first-app-0..
2021-06-30 10:33:52.602575 [ThreadId 178] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-5567a8a334ae91394d5e425fb1fa4c14cd51694d
2021-06-30 10:33:52.602791 [ThreadId 178] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-5567a8a334ae91394d5e425fb1fa4c14cd51694d
2021-06-30 10:33:52.602933 [ThreadId 178] INFO hls: Making new HscEnv[main,main]
2021-06-30 10:33:52.612451 [ThreadId 306] INFO hls: Consulting the cradle for "test/Spec.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/frankcastellucci/haskell-projects/first-app", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.10.4 -O1
> In order, the following will be built (use -v for more details):
>  - first-app-0 (test:first-app-test) (first run)
> Configuring test suite 'first-app-test' for first-app-0..
> Warning: The package has an extraneous version range for a dependency on an
> internal library: first-app >=0 && ==0, first-app >=0 && ==0, first-app >=0 &&
> ==0. This version range includes the current package but isn't needed as the
> current package's library will always be used.
> Preprocessing test suite 'first-app-test' for first-app-0..
2021-06-30 10:33:53.992551 [ThreadId 306] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-57fa401bf0b750deb9ba40cc5fa8efb41740c533
2021-06-30 10:33:53.992777 [ThreadId 306] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-57fa401bf0b750deb9ba40cc5fa8efb41740c533
2021-06-30 10:33:53.992922 [ThreadId 306] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-57fa401bf0b750deb9ba40cc5fa8efb41740c533
2021-06-30 10:33:53.99304 [ThreadId 306] INFO hls:  Making new HscEnv[main,main,main]
2021-06-30 10:33:54.002749 [ThreadId 436] INFO hls: Consulting the cradle for "src/Lib.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/frankcastellucci/haskell-projects/first-app", cradleOptsProg = CradleAction: Cabal}
2021-06-30 10:33:54.012594 [ThreadId 523] INFO hls: File:     /Users/frankcastellucci/haskell-projects/first-app/bench/Main.hs
Hidden:   no
Range:    1:1-1:11
Source:   typecheck
Severity: DsWarning
Message:
  The import of ‘Lib’ is redundant
  except perhaps to import instances from ‘Lib’
  To import instances alone, use: import Lib()
> Build profile: -w ghc-8.10.4 -O1
> In order, the following will be built (use -v for more details):
>  - first-app-0 (lib) (ephemeral targets)
> Preprocessing library for first-app-0..
2021-06-30 10:33:54.245932 [ThreadId 436] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/first-app-0-inplace-61834c7bcd11b8747c5451ce3063e34e87c6269e
2021-06-30 10:33:54.246119 [ThreadId 436] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-21f6835633a77cb19ecaa09366f4a9c1936da48c
2021-06-30 10:33:54.246239 [ThreadId 436] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-21f6835633a77cb19ecaa09366f4a9c1936da48c
2021-06-30 10:33:54.246343 [ThreadId 436] INFO hls: Using interface files cache dir: /Users/frankcastellucci/.cache/ghcide/main-21f6835633a77cb19ecaa09366f4a9c1936da48c
2021-06-30 10:33:54.24644 [ThreadId 436] INFO hls:  Making new HscEnv[first-app-0-inplace,main,main,main]
2021-06-30 10:33:54.312122 [ThreadId 798] INFO hls: File:     /Users/frankcastellucci/haskell-projects/first-app/test/Spec.hs
Hidden:   no
Range:    4:1-4:29
Source:   typecheck
Severity: DsWarning
Message:
  The import of ‘Test.Tasty.QuickCheck’ is redundant
  except perhaps to import instances from ‘Test.Tasty.QuickCheck’
  To import instances alone, use: import Test.Tasty.QuickCheck()
2021-06-30 10:33:54.312446 [ThreadId 841] INFO hls: finish: User TypeCheck (took 0.06s)
2021-06-30 10:33:54.314387 [ThreadId 851] INFO hls: finish: GetHie (took 0.00s)

Completed (4 files worked, 0 files failed)
2021-06-30 10:33:54.31454 [ThreadId 852] INFO hls:  finish: GenerateCore (took 0.00s)

[nix-shell:~/haskell-projects/first-app]$ code .
FrankC01 commented 3 years ago

First note is the exception shown at the beginning of haskell-language-server

But what I did after that, which seems to be working, was:

which haskell-language-server
/nix/store/j8xivmf4j6xmsvq32g86029sh1m2adhj-haskell-language-server-exe-haskell-language-server-1.0.0.0/bin/haskell-language-server

I took that output and put it in vscode settings:Haskell: Server Executable Path which seems to now work.

jonascarpay commented 3 years ago

Your haskell-language-server output looks normal, no issues there.

I'm glad you found something that works, but be aware that this is a fragile solution; you're pinning an exact path in the nix store. Any change in dependencies/versions will change this path and might then cause unexpected breakage after a garbage collect. I'm not familiar with VS Code, but I imagine there should be some way to get it to automatically pick up HLS from PATH. What happens if you set the executable to just haskell-language-server?

FrankC01 commented 3 years ago

I hit that thought earlier today, re-installed Nix and vscode extensions and left everything vanilla and is holding strong. Not sure what I did differently earlier that would cause it to go sideways.

Haskell, Nix and Cabal are all new to me so I'm fairly certain I dropped an egg or two....

Thanks!