Reputation: 133
I have created a stack haskell project a few months ago and finished it then. I wanted to add and fix a few issues it has, but when i tried opening the .hs file on vs code (visual studio code) i got the error in the title, the full one is at the bottom of this question. I tried reinstalling stack, but nothing changed. I also updated the stack.yaml
resolver to the newest lts build, which is 19.9 using the
resolver: url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/9.yaml
The error appears to be that my project is using an older version of ghc that my machine doesn't have, especially since the folder C:\cabal\store\ghc-8.10.7
doesn't exist on my machine, where this is the only one that exists in that path C:\cabal\store\ghc-9.2.1
So my question is, how can i update the version of my GHC for my specific stack project?
The full error: ghcide compiled by GHC 8.10 failed to load packages: haskell-language-server-8.10.7~1.7.0.0.exe: can't find a package database at C:\cabal\store\ghc-8.10.7\package.db. Please ensure that ghcide is compiled with the same GHC installation as the project.
Stack version: 2.7.5
GHCi/GHC version: 8.10.7
IDE: VS code (visual studio code)
Upvotes: 3
Views: 2037
Reputation: 133
Tl;dr If you want to change the version of ghc(i) when you use ghci
then use ghcup set ghc (version number)
. if you want to change it on stack, the use stack config set resolver ghc-(version number)
. Remaking the stack project also helpt me, so maybe try that as well if you are stuck.
This was a hell of a rollercoaster to fix but i finally fixed it. To clarify i think the issue was that i had more than one version of ghc(i), but those different versions were also installed in different ways, for example i have 8.10.7 version on stack, and the 9.2.3 version on cabal, it didn't help i also didn't have the 8.10 ghc(i) version. As you can already tell it was confusing for the compiler as much as it was confusing for me. I tried deleting them and reinstalling different versions, but none of them worked, even after i made sure i added them to path. By not working i mean when iw rite ghc
or ghci
command on terminal they are not recongised. I went back to have the two versions i had (8.10.7 and 9.2.3). I then used the command ghcup set ghc 9.2.3
to set the main ghc version to 9.2.3, now i was able to use the commands ghc
and ghci
again. the command stack ghci
worked, but it only worked outside of my stack project, so i had to remake the project for it work. I also changed the stack ghc(i) version to the latest version by using stack config set resolver ghc-9.2.3
, but then i changed this one back to 9.0.2 as it is the last version that stack recommends.
Upvotes: 1