如何为堆栈项目更新GHC的版本?错误:GHC汇编的GHCIDE 8.10未能加载软件包:Haskell语言服务器-8.10.7

发布于 2025-02-04 00:06:05 字数 731 浏览 4 评论 0原文

几个月前,我创建了一个堆栈Haskell项目,然后完成了。我想添加并修复了一些问题,但是当我尝试在VS代码(Visual Studio Code)上打开.HS文件时,我在标题中遇到了错误,整个问题都位于这个问题的底部。我尝试重新安装堆栈,但没有任何改变。我还将stack.yaml解析器更新为最新的LTS构建,该构建是19.9 解析器:url:https://raw.githubusercontent.com/commermenthaskell/stackage-snapshots/master/master/lts/19/9.yaml 错误似乎是我的项目使用了我的机器没有的旧版本,尤其是因为文件夹c:\ cabal \ store \ ghc-8.10.7不存在在我的计算机上,这是该路径中唯一存在的c:\ cabal \ store \ ghc-9.2.1,所以我的问题是,如何为我的GHC更新我的GHC版本特定的堆栈项目?

完整错误:GHC 8.10编写的GHCIDE 无法加载软件包:Haskell-Language-Server-8.10.7〜1.7.7.0.0.0.exe:找不到C:\ cabal \店\ ghc-- 8.10.7 \ package.db。请确保GHCIDE与项目的安装相同。

stack版本:2.7.5

GHCI/GHC版本:8.10.7

IDE:VS Code(Visual Studio Code)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ヤ经典坏疍 2025-02-11 00:06:06

tl; dr如果要在使用ghci时更改GHC(i)的版本,然后使用ghcup set ghc(verion number)。如果要在堆栈上更改它,则使用stack config set set resolver ghc-(版本号)。重新制作堆栈项目也为我服务,所以如果您被卡住,也可以尝试一下。

这是一个过山车的地狱,但我终于修复了它。为了澄清我认为问题是我有多个版本的GHC(i),但是这些不同的版本也以不同的方式安装,这无济于事,我也没有8.10 GHC(i)版本。正如您已经说出的那样,这对编译器来说是令人困惑的,因为它令我感到困惑。我尝试删除它们并重新安装不同的版本,但是即使我确保将它们添加到路径之后,它们都没有起作用。通过不工作,我的意思是当IW Rite GHCGHCI命令上时,它们不会重新调用。我回去拥有两个版本(8.10.7和9.2.3)。然后,我使用命令GHCUP设置GHC 9.2.3将主要GHC版本设置为9.2.3,现在我能够使用命令ghcghci再次。命令stack ghci工作起来,但它仅在我的堆栈项目之外工作,因此我不得不重新制作该项目以工作。我还使用stack config set resolver ghc-9.2.3将堆栈GHC(i)版本更改为最新版本,但随后我将其更改为9.0.2该堆栈推荐。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文