3

Hello guys i am trying to install ghc-mod for vscode and i am running into this issue:

**$ stack install ghc-mod**
Populated index cache.

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for ghc-mod-5.8.0.0:
    Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25 (latest matching version
                  is 1.24.2.0)
    base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && <4.10  (latest matching
                  version is 4.9.1.0)
    mcabal-helper must match <0.8 && >=0.7.3.0, but the stack configuration has no specified version
                 (latest matching version is 0.7.3.0)
    extra-1.6.8 from stack configuration does not match <1.6 && >=1.4  (latest matching version
                is 1.5.3)
    ghc-8.2.2 from stack configuration does not match >=7.6 && <8.2
    haskell-src-exts-1.20.2 from stack configuration does not match <1.20 && >=1.18  (latest
                            matching version is 1.19.1)
    hlint-2.1.6 from stack configuration does not match <2.1 && >=2.0.8  (latest matching version
                is 2.0.15)
    monad-journal-0.8.1 from stack configuration does not match <0.8 && >=0.4  (latest matching
                        version is 0.7.2)
    optparse-applicative-0.14.2.0 from stack configuration does not match >=0.13.0.0 && <0.14
                                  (latest matching version is 0.13.2.0)
needed since ghc-mod is a build target.

Some different approaches to resolving this:

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some
    working build configuration. This can be convenient when dealing with many complicated
    constraint errors, but results may be unpredictable.

  * Recommended action: try adding the following to your extra-deps
    in C:\sr\global-project\stack.yaml:

- Cabal-1.24.2.0
- base-4.9.1.0
- cabal-helper-0.7.3.0
- extra-1.5.3
- haskell-src-exts-1.19.1
- hlint-2.0.15
- monad-journal-0.7.2
- optparse-applicative-0.13.2.0

Plan construction failed.

I have tried stack install ghc-mod and cabal install ghc-mod to no avail.I always get this plan construction failed.Any ideas on how to deal with it?
P.S:I have already updated both stack and cabal.

After following the advice of a user i added the files to the C:\sr\global-project/stack.yaml and now it looks like this :

Global stack.yaml :

packages: []
resolver: lts-11.13
 Cabal-1.24.2.0
 base-4.9.1.0
 cabal-helper-0.7.3.0
 extra-1.5.3
 haskell-src-exts-1.19.1
 hlint-2.0.15
 monad-journal-0.7.2
 optparse-applicative-0.13.2.0

After i added all these files i get the following error when running stack install ghc-mod :

$ stack install ghc-mod

    Unable to load custom resolver lts-11.13 Cabal-1.24.2.0 base-4.9.1.0 cabal-helper-0.7.3.0 extra-1.5.3 haskell-src-exts-1.19.1 hlint-2.0.15 monad-journal-0.7.2 optparse-applicative-0.13.2.0 from local file:
      C:\sr\global-project\lts-11.13 Cabal-1.24.2.0 base-4.9.1.0 cabal-helper-0.7.3.0 extra-1.5.3 haskell-src-exts-1.19.1 hlint-2.0.15 monad-journal-0.7.2 optparse-applicative-0.13.2.0
    Exception: InvalidYaml (Just (YamlException "Yaml file not found: C:\\sr\\global-project\\lts-11.13 Cabal-1.24.2.0 base-4.9.1.0 cabal-helper-0.7.3.0 extra-1.5.3 haskell-src-exts-1.19.1 hlint-2.0.15 monad-journal-0.7.2 optparse-applicative-0.13.2.0"))
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
  • What is your `resolver` value in your `C:\sr\global-project\stack.yaml`? Maybe try to update to the latest version `lts-8.24` – Yuan Wang Jul 12 '18 at 02:01
  • In my current project i do not have a `stack.yaml` file.I just made some modules and load them in the `ghci`.Or i use `ghc` directly.I have searched for the `.yaml` file and i have more of them for earlier projects but not a global one.They were: one was `lts-11.0` and another was `10.8`. – Bercovici Adrian Jul 12 '18 at 06:13
  • I added all the files in the `C:\sr\global-project\stack.yaml` – Bercovici Adrian Jul 12 '18 at 08:24
  • sorry, should it be " C:\src\global-project" rather than " C:\sr\global-project" ? I am not familiar with how stack works on windows – Yuan Wang Jul 13 '18 at 21:16

2 Answers2

6

The problem is that ghc-mod does not work on ghc-8.2. The latest Stack resolver that supports ghc-mod seems to be lts-9.21.

ghc-mod has to be compiled with the same version of GHC you are using, so right now that constrains you to 8.0.

Edit (August 2020): ghc-mod has been deprecated in favour of the Haskell IDE Engine (HIE).

Paul Johnson
  • 17,438
  • 3
  • 42
  • 59
  • And how can i go back to that version on the global settings? – Bercovici Adrian Jul 12 '18 at 20:14
  • You need to put "resolver: lts-9.2.1" in your global stack.yaml file. – Paul Johnson Jul 13 '18 at 08:23
  • I did that and now i ge the following error : `$ stack install ghc-mod Unable to load custom resolver lts-9.2.1 from local file: C:\sr\global-project\lts-9.2.1 Exception: InvalidYaml (Just (YamlException "Yaml file not found: C:\\sr\\global-project\\lts-9.2.1"))` – Bercovici Adrian Jul 13 '18 at 14:18
1

ghc-mod is clearly unused by most people working with the latest toolchain or else this would work. Consider abandoning it too.

codeshot
  • 1,183
  • 1
  • 9
  • 20