Vscode 失败,无法加载模块“Database.SQLite.Simple”,而 HLS 和 cabal 通过

Vscode fails with Could not load module ‘Database.SQLite.Simple’ while HLS and cabal pass

提问人:uninterestedSwift 提问时间:11/12/2023 最后编辑:uninterestedSwift 更新时间:11/13/2023 访问量:41

问:

我正在尝试测试在 haskell 中编写一个简单的 CRUD 应用程序。 我安装了 VSCode Haskell 扩展,它适用于简单文件,但对于 Main.hs 中的那些导入,我收到错误:

import Database.SQLite.Simple
import Database.SQLite.Simple.FromRow

错误:

Could not load module ‘Database.SQLite.Simple’
It is a member of the hidden package ‘sqlite-simple-0.4.18.2’.
You can run ‘:set -package sqlite-simple’ to expose it.
(Note: this unloads all the modules in the current scope.)

我的样子是这样的:.cabal

executable generate-hs
    main-is:          Main.hs

    other-modules:    HtmlGen

    build-depends:    
        base ^>=4.17.2.0,
        sqlite-simple ^>=0.4.18.2,
        scotty,
        aeson,
        time,
        text,
        blaze-html,
        blaze-markup

    hs-source-dirs:   app
    default-language: Haskell2010

运行通道,设置适当的 Scotty 实例 VSCode 扩展配置为用于查找haskell-language-servercabal run~/.ghcup

到目前为止我尝试过什么:
我尝试添加到路径并使用它,我尝试重新启动所有内容的相同结果
,我通过
查看全局安装的相同结果
,但那里没有 sqlite-simple
~/.ghcupsqlite-simplecabal install --lib sqlite-simple, same resultsghc-pkg

如何解决此错误? 我应该从哪里开始调试?

任何帮助不胜感激

相关版本:

Glasgow Haskell Compiler, Version 9.4.7
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal librar
haskell-language-server version: 2.4.0.0 (GHC: 9.4.7) (PATH: /Users/someone/.ghcup/hls/2.4.0.0/lib/haskell-language-server-2.4.0.0/bin/haskell-language-server-9.4.7)
vscode extension: v2.4.1

基于注释的附加: 视图(在 VSCode 中)-> Haskell

2023-11-12T16:46:22.199302Z | Info | Live bytes: 334.59MB Heap size: 1419.77MB
[Error - 17:47:05] Request textDocument/foldingRange failed.
  Message: codeRange: Rule Failed: GetCodeRange
  Code: -32803 
[Error - 17:47:08] Request textDocument/foldingRange failed.
  Message: codeRange: Rule Failed: GetCodeRange
  Code: -32803 

当前hie.yaml

cradle:
  cabal:
    component: "exe:generate-hs"

dependencies:
  - sqlite-simple
haskell vscode-extensions cabal haskell-language-server

评论

0赞 Noughtmare 11/13/2023
你能发布 Haskell 扩展的输出日志吗?转到“查看>输出”,然后从下拉列表中选择“Haskell (haskell)”。另外,错误是在 Main.hs 还是 HtmlGen.hs(或其他文件)中?您也可以尝试按照此处所述制作文件:github.com/haskell/hie-bios#cabalhie.yamlcradle: cabal:
0赞 uninterestedSwift 11/13/2023
@Noughtmare我尝试了这些步骤,但都没有帮助,如果我做错了什么,请查看票证。
0赞 Noughtmare 11/13/2023
您是否也尝试过只有 and 线而没有其他内容的最小值?这应该足够了,除非阴谋集团里有个错误。您使用的当前文件可能存在问题,但该组件是可执行文件,因此应该是 .hie.yamlcradle:cabal:lib:generate-hsexe:generate-hs
0赞 uninterestedSwift 11/13/2023
@Noughtmare看到更新的,但错误仍然存在hie.yaml
0赞 lsmor 11/13/2023
非常罕见。文件可以更简单(即你的前两行)就这么简单。在 vscode 中,转到 hls 配置并设置为 debug。输出应该在某个时候显示一个阴谋集团错误,复制粘贴hie.yamlcradle:<newline><twospaces>cabal:Haskell > trace > client

答: 暂无答案